-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
131 lines (108 loc) · 4.85 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* update gradle with the command: ./gradlew wrapper --gradle-version=6.7.1 --distribution-type=all
**/
buildscript {
ext {
appVersion = "0.9.2"
appName = "ragde_java_api"
springBootVersion = "2.4.1"
}
repositories {
jcenter()
}
dependencies {
//needed for org.springframework.boot plugin
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('net.ltgt.gradle:gradle-apt-plugin:0.21') //needed for net.ltgt.apt-idea plugin
}
}
plugins {
id "idea" //when IntelliJ builds the project, save .class files in buildDir
//id "war" //uncomment to create a war instead of a jar
id "application" //for sourceCompatibility
id "jacoco" //junit code coverage
id "net.ltgt.apt-idea" version "0.21" //allow idea to find querydsl generated files
id "org.springframework.boot" version "2.4.1" //allow to use ./gradlew bootRun
id "com.github.ben-manes.versions" version "0.36.0" //allow to use ./gradlew dependencyUpdates
}
sourceCompatibility = JavaVersion.VERSION_15
targetCompatibility = JavaVersion.VERSION_15
version = appVersion
jar { archiveBaseName = appName } //change to war if you want to create a war instead of a jar
jacoco { toolVersion = "0.8.6" }
//build
mainClassName = "ragde.Application"
//debug
applicationDefaultJvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"]
//pass gradle properties to spring
//for example running ./gradlew bootRun -Dspring.profiles.active=profile
//pass spring.profiles.active=profile property to spring
bootRun.systemProperties = System.properties
//compile and notify spring devtools when code change
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/java/main/") //move compiled changes where spring devtools can watch them
testOutputDir = file("$buildDir/classes/test/") //not create extra folder like out or classes
}
}
repositories {
jcenter()
}
dependencies {
//recompile on changes, IDEA must enable Build project automatically or Run Build Project for manual
implementation("org.springframework.boot:spring-boot-devtools:${springBootVersion}")
//for rest
implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
//for GraphQL SPQR
implementation("io.leangen.graphql:graphql-spqr-spring-boot-starter:0.0.4")
//for security
implementation("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
implementation("io.jsonwebtoken:jjwt:0.9.1") //json web token
implementation("commons-codec:commons-codec:1.15") //hash
//OAuth
implementation("org.springframework.social:spring-social-facebook:2.0.3.RELEASE")
implementation("com.github.spring-social:spring-social-google:1.1.3")
//WebSocket
implementation("org.springframework.boot:spring-boot-starter-websocket:${springBootVersion}")
//for setter and getter annotations
implementation("org.projectlombok:lombok:1.18.16")
annotationProcessor("org.projectlombok:lombok:1.18.16")
//for swagger REST documentation
implementation("org.springdoc:springdoc-openapi-ui:1.5.2")
//querydsl
implementation("com.querydsl:querydsl-jpa:4.4.0") //allow querydsl with JPA (MySQL)
implementation("com.querydsl:querydsl-mongodb:4.4.0") //allow querydsl with mongodb
implementation("com.querydsl:querydsl-apt:4.4.0:jpa") //generate querydsl Objects
annotationProcessor(
"com.querydsl:querydsl-apt:4.4.0:jpa",
"org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2",
"javax.annotation:javax.annotation-api:1.3.2"
)
//jpa
implementation("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
implementation("com.h2database:h2:1.4.200")
implementation("mysql:mysql-connector-java:8.0.22")
implementation("org.mongodb:mongo-java-driver:3.12.7")
//mongodb
implementation("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootVersion}")
//providedRuntime is needed where you want to compile a war
//providedRuntime("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion}")
//test
testImplementation("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
testImplementation("org.hibernate:hibernate-validator:6.1.5.Final")
}
test {
useJUnitPlatform()
}
//update version at application.properties
def updateApplicationProperties() {
def configFile = new File("src/main/resources/application.properties")
println "updating version to '${version}' in ${configFile}"
String configContent = configFile.getText("UTF-8")
configContent = configContent.replaceAll(/api-version=.*/, "api-version=${version}")
configFile.write(configContent, "UTF-8")
}
allprojects {
updateApplicationProperties()
}