forked from michel-kraemer/vertx-lang-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
277 lines (237 loc) · 9.94 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
plugins {
id 'com.moowork.node' version '0.10'
id 'de.undercouch.download' version '2.0.0'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
import de.undercouch.gradle.tasks.download.Download
version = '1.0.0'
group = 'de.undercouch'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
ext {
vertxVersion = '3.1.0'
vertxExamplesSHA = '6a31a51d85707f0471cf80cbaa6b21265a2f754e'
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
configurations {
vertx
codegen
}
dependencies {
compile "io.vertx:vertx-core:$vertxVersion"
compile "io.vertx:vertx-lang-js:$vertxVersion"
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-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-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:1.3.0'
codegen 'de.neuland-bfi:jade4j:0.4.0'
codegen 'io.dropwizard.metrics:metrics-core:3.1.0'
codegen 'io.reactivex:rxjava:1.0.0-rc.3'
codegen 'log4j:log4j:1.2.16'
codegen 'org.slf4j:slf4j-api:1.6.2'
codegen 'org.thymeleaf:thymeleaf:2.1.2.RELEASE'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
// 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:git@github.com: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 'michel@undercouch.de'
}
}
}
}
}
}
node {
version = '0.12.4'
npmVersion = '2.1.6'
download = true
}
sourceSets {
main {
resources {
srcDir 'src-gen/main/resources'
}
}
}
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)
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
def urls = cp.files.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, "web-examples"), typingsDir, null, null)
}
test {
forkEvery = 1
maxParallelForks = 1
maxHeapSize = '512m'
}
test.dependsOn(testExamples)