-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
332 lines (286 loc) · 11.6 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
buildscript {
dependencies {
classpath 'org.apache.commons:commons-lang3:3.4'
}
}
plugins {
id 'com.moowork.node' version '0.12'
id 'de.undercouch.download' version '2.1.0'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
import de.undercouch.gradle.tasks.download.Download
import org.apache.commons.lang3.SystemUtils
version = '1.2.0-SNAPSHOT'
group = 'de.undercouch'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
ext {
vertxVersion = '3.2.1'
vertxExamplesSHA = '067d8c9624dc5b82c706bcebcaadcdfe3ecc5ca0'
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
configurations {
provided
vertx
codegen
}
def getV8Dependency() {
def arch = System.getProperty('os.arch')
def dep = null
if (SystemUtils.IS_OS_WINDOWS) {
dep = 'win32_x86'
if (arch.equals('amd64')) {
dep += '_64'
}
} else if (SystemUtils.IS_OS_MAC && (arch.equals('amd64') || arch.equals('x86_64'))) {
dep = 'macosx_x86_64'
} else if (SystemUtils.IS_OS_LINUX && arch.equals('amd64')) {
dep = 'linux_x86_64'
}
if (dep == null) {
logger.error("Could not find V8 runtime compatible to this system")
return null
}
return 'com.eclipsesource.j2v8:j2v8_' + dep + ':3.1.1'
}
dependencies {
compile "io.vertx:vertx-core:$vertxVersion"
compile "io.vertx:vertx-lang-js:$vertxVersion"
// compile-time dependencies
if (getV8Dependency() != null) {
provided getV8Dependency()
}
testCompile 'junit:junit:4.12'
testCompile "io.vertx:vertx-web:$vertxVersion"
testCompile "io.vertx:vertx-unit:$vertxVersion"
testCompile 'commons-io:commons-io:2.4'
vertx group: 'io.vertx', name: 'vertx-auth-common', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-auth-jdbc', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-auth-jwt', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-auth-oauth2', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-auth-shiro', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-core', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-dropwizard-metrics', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-jdbc-client', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-mail-client', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-mail-service', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-mongo-client', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-redis-client', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-rx-java', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-service-proxy', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-shell', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-sql-common', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-web', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-web-templ-thymeleaf', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-web-templ-handlebars', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-web-templ-jade', version: vertxVersion, classifier: 'sources'
vertx group: 'io.vertx', name: 'vertx-web-templ-mvel', version: vertxVersion, classifier: 'sources'
codegen "io.vertx:vertx-auth-shiro:$vertxVersion"
codegen "io.vertx:vertx-core:$vertxVersion"
codegen "io.vertx:vertx-codegen:$vertxVersion"
codegen "io.vertx:vertx-docgen:$vertxVersion"
codegen "io.vertx:vertx-jdbc-client:$vertxVersion"
codegen "io.vertx:vertx-mongo:$vertxVersion"
codegen "io.vertx:vertx-web:$vertxVersion"
codegen 'com.github.jknack:handlebars:4.0.1'
codegen 'com.jolbox:bonecp:0.8.0.RELEASE'
codegen 'com.zaxxer:HikariCP:2.4.3'
codegen 'de.neuland-bfi:jade4j:1.1.3'
codegen 'io.dropwizard.metrics:metrics-core:3.1.2'
codegen 'io.reactivex:rxjava:1.1.0'
codegen 'io.termd:termd-core:1.0.1'
codegen 'log4j:log4j:1.2.17'
codegen 'org.apache.sshd:sshd-core:1.0.0'
codegen 'org.slf4j:slf4j-api:1.7.13'
codegen 'org.thymeleaf:thymeleaf:2.1.4.RELEASE'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
// add 'provided' configuration to javadoc classpath
javadoc {
classpath += configurations.provided
}
// package javadoc into a jar file
task packageJavadoc(type: Jar, dependsOn: 'javadoc') {
from javadoc.destinationDir
classifier = 'javadoc'
}
// package source into a jar file
task packageSources(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
// remove test dependencies from configuration-to-scope mapping
// this also removes them from the maven pom file
conf2ScopeMappings.mappings.remove(configurations.testCompile)
uploadArchives {
repositories {
mavenDeployer {
// sign artifacts before upload
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
// upload to sonatype OSS
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
authentication(userName: this.hasProperty('sonatypeUsername') ? sonatypeUsername : '',
password: this.hasProperty('sonatypePassword') ? sonatypePassword : '')
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: this.hasProperty('sonatypeUsername') ? sonatypeUsername : '',
password: this.hasProperty('sonatypePassword') ? sonatypePassword : '')
}
// pom file details
pom.project {
name 'vertx-lang-typescript'
packaging 'jar'
description 'TypeScript support for Vert.x 3.0'
url 'https://github.com/michel-kraemer/vertx-lang-typescript'
scm {
url 'https://github.com/michel-kraemer/vertx-lang-typescript'
connection 'scm:git:git://github.com/michel-kraemer/vertx-lang-typescript.git'
developerConnection 'scm:git:ssh:[email protected]:michel-kraemer/vertx-lang-typescript.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'michel-kraemer'
name 'Michel Kraemer'
email '[email protected]'
}
}
}
}
}
}
node {
version = '5.10.0'
npmVersion = '3.8.6'
download = true
}
sourceSets {
main {
resources {
srcDir 'src-gen/main/resources'
}
// add 'provided' configuration to compile classpath
compileClasspath += configurations.provided
}
}
task copyVertx(type: Copy) {
from {
configurations.vertx.collect { zipTree(it) }
}
into new File(buildDir, 'vertx')
include "io/vertx/**"
}
task generateTypeDefinitions(type: JavaCompile, dependsOn: copyVertx) {
source = new File(buildDir, 'vertx')
classpath = configurations.codegen + files(sourceSets.main.resources.srcDirs)
options.compilerArgs = [
'-proc:only',
'-processor', 'io.vertx.codegen.CodeGenProcessor',
'-AoutputDirectory=' + new File(buildDir, 'generated'),
]
destinationDir = new File(buildDir, 'generated')
}
task copyGeneratedTypeDefinitions(type: Copy, dependsOn: generateTypeDefinitions) {
def level = 0
from new File(generateTypeDefinitions.destinationDir, 'resources')
into new File(buildDir, 'typings')
filter { line ->
line.trim().isEmpty() ? null : line
}
filter { line ->
if (line.endsWith('{')) {
level++
} else if (line.endsWith('}')) {
level --
}
if (level > 0) {
return line.startsWith(' * ') ? " $line" : line
} else {
return line
}
}
filter { line ->
line.trim() == '/**' || line.startsWith('declare ') ? "\n$line" : line
}
}
task copyTypeDefinitions(type: Copy, dependsOn: copyGeneratedTypeDefinitions) {
from new File(projectDir, 'src/main/typings')
into new File(buildDir, 'typings')
}
task copyRequiredResources(type: Copy, dependsOn: [copyTypeDefinitions, npmInstall]) {
from file('node_modules/typescript')
into 'src-gen/main/resources/typescript'
}
task typeDefinitionsZip(type: Zip, dependsOn: copyTypeDefinitions) {
from new File(buildDir, 'typings')
classifier = 'typings'
}
// define artifacts for upload
artifacts {
archives jar
archives packageJavadoc
archives packageSources
archives typeDefinitionsZip
}
// sign all artifacts
signing {
required { gradle.taskGraph.hasTask(uploadArchives) }
sign configurations.archives
}
processResources.dependsOn(copyRequiredResources)
eclipseClasspath.dependsOn(processResources)
// add 'provided' to eclipse classpath
eclipse {
classpath {
plusConfigurations += [configurations.provided]
}
}
assemble.dependsOn(typeDefinitionsZip)
task downloadExamples(type: Download) {
src "https://github.com/vert-x3/vertx-examples/archive/${vertxExamplesSHA}.zip"
dest new File(buildDir, 'vertx-examples.zip')
overwrite false
}
task unzipExamples(dependsOn: downloadExamples, type: Copy) {
from zipTree(downloadExamples.dest)
into buildDir
}
task testExamples(dependsOn: [ unzipExamples, testClasses ]) << {
def cp = project.test.classpath + configurations.provided
def urls = cp.collect { it.toURI().toURL() }
def cl = new URLClassLoader(urls.toArray(new URL[urls.size()]))
def cls = cl.loadClass("de.undercouch.vertx.lang.typescript.TestExamplesRunner")
def runner = cls.newInstance()
def examplesDir = new File(buildDir, "vertx-examples-$vertxExamplesSHA")
def typingsDir = new File(buildDir, 'typings')
runner.run(new File(examplesDir, "core-examples"), typingsDir, null, null)
runner.run(new File(examplesDir, "jdbc-examples"), typingsDir, null, null)
runner.run(new File(examplesDir, "mail-examples"), typingsDir, null, null)
runner.run(new File(examplesDir, "metrics-examples"), typingsDir, null, null)
runner.run(new File(examplesDir, "mongo-examples"), typingsDir, null, null)
runner.run(new File(examplesDir, "redis-examples"), typingsDir, null, null)
runner.run(new File(examplesDir, "shell-examples"), typingsDir, null, null)
runner.run(new File(examplesDir, "web-examples"), typingsDir, null, null)
}
test {
forkEvery = 1
maxParallelForks = 1
maxHeapSize = '512m'
}
test.dependsOn(testExamples)