1
- import org.vertx.java.core.AsyncResult
2
- import org.vertx.java.core.AsyncResultHandler
3
- import org.vertx.java.platform.PlatformLocator
4
- import org.vertx.java.platform.impl.ModuleClassLoader
5
-
6
- import java.util.concurrent.CountDownLatch
7
- import java.util.concurrent.TimeUnit
1
+ import org.vertx.java.platform.impl.cli.Starter
8
2
9
3
/*
10
4
* Copyright 2012 the original author or authors.
@@ -27,6 +21,8 @@ apply plugin: 'scala'
27
21
apply plugin : ' idea'
28
22
apply plugin : ' eclipse'
29
23
24
+ def cpSeparator = System . getProperty(" path.separator" )
25
+
30
26
// We have to explicitly load props from the user home dir - on CI we set
31
27
// GRADLE_USER_HOME to a different dir to avoid problems with concurrent builds corrupting
32
28
// a shared Maven local and using Gradle wrapper concurrently
@@ -44,13 +40,6 @@ targetCompatibility = '1.7'
44
40
45
41
project. ext. moduleName = " $modowner ~$modname ~$version "
46
42
47
- if (produceJar == ' false' ) {
48
- jar. enabled = false
49
- assert configurations. archives. artifacts. removeAll { it. file == jar. archivePath }
50
- } else {
51
-
52
- }
53
-
54
43
configurations {
55
44
provided
56
45
testCompile. extendsFrom provided
@@ -91,6 +80,8 @@ buildscript {
91
80
dependencies {
92
81
classpath " io.vertx:vertx-core:$vertxVersion "
93
82
classpath " io.vertx:vertx-platform:$vertxVersion "
83
+ classpath " io.vertx:vertx-hazelcast:$vertxVersion "
84
+ classpath files([' src/main/resources' ])
94
85
}
95
86
}
96
87
@@ -119,10 +110,26 @@ task modZip( type: Zip, dependsOn: 'pullInDeps', description: 'Package the modul
119
110
from copyMod
120
111
}
121
112
113
+ task sourceJar (type : Jar ) {
114
+ description = ' Builds a source jar artifact suitable for maven deployment.'
115
+ classifier = ' sources'
116
+ from sourceSets. main. java
117
+ }
118
+
119
+ task javadocJar (type : Jar ) {
120
+ description = ' Builds a javadoc jar artifact suitable for maven deployment.'
121
+ classifier = ' javadoc'
122
+ from javadoc. destinationDir
123
+ }
124
+ javadocJar. dependsOn javadoc
125
+
126
+ build. dependsOn sourceJar, javadocJar
127
+
122
128
artifacts {
123
- archives modZip
129
+ archives sourceJar, javadocJar, modZip
124
130
}
125
131
132
+
126
133
test {
127
134
dependsOn copyMod
128
135
@@ -137,82 +144,61 @@ test {
137
144
systemProperty ' vertx.mods' , " build/mods"
138
145
}
139
146
140
- task runModIDEA (dependsOn : copyMod, description : ' Run the module from the resources in IntelliJ' ) << {
141
- def classpath = [ new URL (' file:src/main/resources/' ), new URL (' file:src/test/resources/' ),
142
- new URL (" file:out/production/${ project.name} /" ), new URL (" file:out/test/${ project.name} /" )] as URL []
143
-
144
- println " file:out/production/${ project.name} "
145
- runModWithClasspath(classpath)
146
- }
147
-
148
- task runModEclipse (dependsOn : copyMod, description : ' Run the module from the resources in Eclipse' ) << {
149
- def classpath = [ new URL (' file:src/main/resources/' ), new URL (' file:src/test/resources/' ), new URL (' file:bin/' )] as URL []
150
- runModWithClasspath(classpath)
151
- }
152
-
153
- def runModWithClasspath (URL [] classpath ) {
147
+ task init (description : ' Create module link and CP file' ) << {
154
148
setSysProps()
155
- def pm = PlatformLocator . factory. createPlatformManager()
156
- def latch = new CountDownLatch (1 )
157
- pm. deployModuleFromClasspath(moduleName, null , 1 , classpath, new
158
- AsyncResultHandler<String > () {
159
- public void handle(AsyncResult<String > asyncResult) {
160
- if (asyncResult. succeeded()) {
161
- println " CTRL-C to stop server"
162
- } else {
163
- println " Failed to deploy module"
164
- asyncResult. cause(). printStackTrace()
165
- latch. countDown()
166
- }
167
- }
168
- });
169
- latch. await(Long . MAX_VALUE , TimeUnit . MILLISECONDS );
149
+ doInit()
170
150
}
171
151
172
- task runMod (dependsOn : copyMod, description : ' Run the module using all the build dependencies (not using installed vertx ' ) << {
152
+ task runMod (description : ' Run the module' ) << {
173
153
setSysProps()
174
154
System . setProperty(" vertx.langs.scala" , " io.vertx~lang-scala~${ scalaLangModVersion} :org.vertx.scala.platform.impl.ScalaVerticleFactory" )
175
- def pm = PlatformLocator . factory. createPlatformManager()
176
- def latch = new CountDownLatch (1 )
177
-
178
- pm. deployModule(moduleName, null , 1 , new AsyncResultHandler<String > () {
179
- public void handle (AsyncResult<String > asyncResult ) {
180
- if (asyncResult. succeeded()) {
181
- println " CTRL-C to stop server"
182
- } else {
183
- println " Failed to deploy module"
184
- asyncResult. cause(). printStackTrace()
185
- latch. countDown()
186
- }
187
- }
188
- });
189
- latch. await(Long . MAX_VALUE , TimeUnit . MILLISECONDS );
155
+ // We also init here - this means for single module builds the user doesn't have to explicitly init -
156
+ // they can just do runMod
157
+ doInit()
158
+ args = [' runmod' , moduleName]
159
+ def args2 = runModArgs. split(" \\ s+" )
160
+ args. addAll(args2)
161
+ Starter . main(args as String [])
162
+ }
163
+
164
+ def doInit () {
165
+ File cpFile = new File (" vertx_classpath.txt" )
166
+ if (! cpFile. exists()) {
167
+ cpFile. createNewFile();
168
+ String defaultCp =
169
+ " src/main/resources\r\n " +
170
+ " bin\r\n " +
171
+ " out/production/${ project.name} \r\n " +
172
+ " out/test/${ project.name} " ;
173
+ cpFile << defaultCp;
174
+ }
175
+ def args = [' create-module-link' , moduleName]
176
+ Starter . main(args as String [])
190
177
}
191
178
192
179
task pullInDeps (dependsOn : copyMod, description : ' Pull in all the module dependencies for the module into the nested mods directory' ) << {
193
180
if (pullInDeps == ' true' ) {
194
181
setSysProps()
195
- def pm = PlatformLocator . factory. createPlatformManager()
196
- def latch = new CountDownLatch (1 )
197
- println " Pulling in dependencies for module $moduleName . Please wait"
198
- pm. pullInDependencies(moduleName, new AsyncResultHandler<Void > () {
199
- public void handle (AsyncResult<Void > asyncResult ) {
200
- if (asyncResult. succeeded()) {
201
- println " Dependencies pulled in successfully"
202
- latch. countDown()
203
- } else {
204
- println " Failed to pull in dependencies"
205
- asyncResult. cause(). printStackTrace()
206
- latch. countDown()
207
- }
208
- }
209
- })
210
- latch. await(Long . MAX_VALUE , TimeUnit . MILLISECONDS );
182
+ def args = [' pulldeps' , moduleName]
183
+ Starter . main(args as String [])
184
+ }
185
+ }
186
+
187
+ task fatJar (dependsOn : modZip, description : ' Creates a fat executable jar which contains everything needed to run the module' ) << {
188
+ if (createFatJar == ' true' ) {
189
+ setSysProps()
190
+ def args = [' fatjar' , moduleName, ' -d' , ' build/libs' ]
191
+ Starter . main(args as String [])
211
192
}
212
193
}
213
194
214
195
def setSysProps () {
215
- System . setProperty(" vertx.mods" , " build/mods" )
196
+ System . setProperty(" vertx.clusterManagerFactory" , " org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory" )
197
+ String modsDir = System . getenv(" VERTX_MODS" )
198
+ if (modsDir == null ) {
199
+ modsDir = " build/mods" ;
200
+ }
201
+ System . setProperty(" vertx.mods" , modsDir)
216
202
}
217
203
218
204
def loadProperties (String sourceFileName ) {
0 commit comments