forked from campudus/tableaux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
executable file
·235 lines (184 loc) · 5.3 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!groovy
import java.nio.file.Paths
import java.text.SimpleDateFormat
plugins {
id 'java'
id 'scala'
id 'application'
id 'org.scoverage' version '2.1.0'
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'com.github.johnrengelman.shadow' version '2.0.1'
id 'org.ajoberstar.grgit' version '2.1.0'
id 'com.diffplug.gradle.spotless' version '3.6.0'
}
project.group = 'com.campudus'
project.version = '0.1.0'
def vertxVersion = '3.5.0'
def scalaVersion = '2.12.4'
sourceCompatibility = '1.8'
repositories {
jcenter()
}
configurations {
compileOnly
}
dependencies {
compile "org.scala-lang:scala-library:${scalaVersion}"
// add scala-reflect to keep dependencies up-to-date
compile "org.scala-lang:scala-reflect:${scalaVersion}"
compile "io.vertx:vertx-core:${vertxVersion}"
compile "io.vertx:vertx-web:${vertxVersion}"
compile "io.vertx:vertx-mysql-postgresql-client:${vertxVersion}"
// add Vert.x Scala
compile "io.vertx:vertx-lang-scala_2.12:${vertxVersion}"
compile "io.vertx:vertx-web-scala_2.12:${vertxVersion}"
compile "io.vertx:vertx-mysql-postgresql-client-scala_2.12:${vertxVersion}"
compile 'joda-time:joda-time:2.9.9'
compile 'com.typesafe.scala-logging:scala-logging_2.12:3.7.2'
compile 'org.slf4j:slf4j-jdk14:1.7.25'
compile 'com.jcabi:jcabi-manifests:1.1'
compile 'com.github.cb372:scalacache-guava_2.12:0.10.0'
//compile 'org.webjars:swagger-ui:3.0.3'
compile 'org.webjars:swagger-ui:2.2.10-1'
compileOnly "io.vertx:vertx-codegen:${vertxVersion}"
// scala version for scoverage must be the same
scoverage "org.scala-lang:scala-library:${scalaVersion}"
scoverage 'org.scoverage:scalac-scoverage-plugin_2.12:1.3.1'
scoverage 'org.scoverage:scalac-scoverage-runtime_2.12:1.3.1'
testCompile "io.vertx:vertx-unit:${vertxVersion}"
testCompile 'junit:junit:4.12'
}
mainClassName = "io.vertx.core.Launcher"
def mainVerticle = "scala:com.campudus.tableaux.Starter"
test {
maxHeapSize = "512m"
// http://www.oracle.com/technetwork/java/javase/relnotes-139183.html#vm
// https://stackoverflow.com/a/4659279/104779
jvmArgs = ["-Xmx512m", "-XX:-OmitStackTraceInFastThrow"]
}
testScoverage {
maxHeapSize = "512m"
// http://www.oracle.com/technetwork/java/javase/relnotes-139183.html#vm
// https://stackoverflow.com/a/4659279/104779
jvmArgs = ["-Xmx512m", "-XX:-OmitStackTraceInFastThrow"]
}
run {
def configFile = "conf.json"
if (project.hasProperty("conf")) {
configFile = conf
} else {
println("Using default config file 'conf.json'")
}
args = [
"run",
mainVerticle,
"-conf", configFile
]
environment ENV: "development"
}
task runRedeploy(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = mainClassName
args = [
"run",
mainVerticle,
"-conf", "conf.json",
"--redeploy=src/main/**/*.scala,src/main/resources/**/*.*",
"--launcher-class=${mainClassName}",
"--on-redeploy=./gradlew classes"
]
environment ENV: "development"
}
tasks.withType(ScalaCompile) {
scalaCompileOptions.additionalParameters = ["-feature"]
}
sourceSets {
main {
compileClasspath += configurations.compileOnly
// let Scala compiler do everything – even java stuff
scala {
srcDirs += "src/main/scala"
srcDirs += "src/main/java"
}
java {
srcDirs = []
}
}
test {
compileClasspath += configurations.compileOnly
}
}
/**
* Code coverage
*/
checkScoverage {
minimumRate = 0.85
}
scoverage {
excludedPackages = [
'io.vertx.scala.*',
'org.vertx.scala.*',
'com.github.mauricio.async.db.*'
]
}
coveralls {
service = "travis-ci"
def coverageReportPath = "${buildDir}/reports/scoverage/cobertura.xml".toString()
def sourceDirsList = new ArrayList<String>()
subprojects.sourceSets.main.allSource.srcDirs.each {
it.each {
def basePath = Paths.get(System.getProperty("user.dir"))
def relPath = basePath.relativize(Paths.get(it.toString()))
sourceDirsList.add(relPath.toString())
}
}
sourceDirs = sourceDirsList
coberturaReportPath = coverageReportPath
}
/**
* Jar stuff
*/
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX") // you can change it
def gitBranch = grgit.branch.current().fullName
def gitCommit = grgit.log(maxCommits: 1).get(0).id
def gitComitterDate = df.format(grgit.log(maxCommits: 1).get(0).date)
def buildTime = df.format(new Date())
def buildJavaVersion = JavaVersion.current().toString()
jar {
manifest {
attributes 'Main-Class': mainClassName
attributes 'Main-Verticle': mainVerticle
attributes 'Implementation-Vendor': project.group
attributes 'Implementation-Title': project.name
attributes 'Implementation-Version': project.version
attributes 'Git-Branch': gitBranch
attributes 'Git-Commit': gitCommit
attributes 'Git-Committer-Date': gitComitterDate
attributes 'Build-Date': buildTime
attributes 'Build-Java-Version': buildJavaVersion
}
}
shadowJar {
classifier = 'fat'
manifest {
inheritFrom project.tasks.jar.manifest
}
mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
}
assemble.dependsOn shadowJar
/**
* scalafmt
*/
spotless {
scala {
scalafmt('1.3.0').configFile('.scalafmt.conf')
}
}
/**
* Gradle wrapper
*/
task wrapper(type: Wrapper) {
gradleVersion = '4.3.1'
}