-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
266 lines (215 loc) · 8.18 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
import java.io.File;
apply plugin: 'eclipse'
apply plugin: 'war'
//version: '2.0.0-SNAPSHOT'
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
repositories {
mavenCentral()
mavenLocal()
// required by: org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-gradle-embedded-archive:2.2.0-alpha-1
maven {
url 'https://repo.gradle.org/gradle/libs-releases-local'
}
maven {
url 'https://repository.jboss.org/nexus/content/groups/public/'
}
// required by jboss51x
maven {
url 'https://repository.jboss.org/nexus/content/repositories/deprecated/'
}
maven {
url 'https://repository.jboss.org/nexus/content/repositories/releases/'
}
// p6spy snapshots
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
ext {
libraryVersions = [
arquillian: '1.1.11.Final',
arquillian_transactions: '1.0.3.Final',
arquillian_spring: '1.1.0.Alpha1',
arquillian_glassfish: '1.0.0.Final',
arquillian_wls: '1.0.1.Final',
arquillian_wlp: '1.0.0.Beta2',
arquillian_wildfly81: "8.2.1.Final",
wildfly81: "8.1.0.CR1",
arquillian_jboss7: '7.2.0.Final',
arquillian_jboss61: '1.0.0.CR3',
jboss61x: '6.1.0.Final',
arquillian_jboss51: '1.0.0.CR3',
jboss51x: '5.1.0.GA',
arquillian_jboss42: '1.0.0.CR3',
jboss42x: '4.2.3.GA',
arquillian_tomcat: '1.0.0.CR7',
shrinkwrap_resolver: '3.0.0-alpha-1',
shrinkwrap_descriptor: '2.0.0-alpha-10',
junit: '4.11',
hamcrest: '1.3',
// jboss 5.1.0 has trouble with 4.0.x versions,
// suggested version (here: https://community.jboss.org/thread/202650) is 3.0.5.RELEASE
spring: (container.equals("jboss51x") ? '3.1.1.RELEASE' : '4.0.4.RELEASE'),
commons_io: '2.4',
liquibase: '3.0.7',
liquibase_slf4j: '1.2.1',
slf4j: '1.7.5',
log4j: '1.2.17',
h2: '1.4.177',
p6spy: '3.0.0',
]
// Export methods by turning them into closures
// see: http://stackoverflow.com/questions/18715137/extract-common-methods-from-gradle-build-script
downloadFile = this.&downloadFile
}
configurations {
provided
h2
p6spyAll { extendsFrom h2 }
}
// Override default 24h module caching in Gradle
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
//configurations.p6spyAll {
// // check for updates on every build
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
//}
dependencies {
// all deps we need to deploy in jar have to be scope: compile/runtime, as we use:
// ShrinkWrap.create(EmbeddedGradleImporter.class)
// .forThisProjectDirectory()
// .importBuildOutput().as(WebArchive.class)
// spring
compile "org.springframework:spring-context:$libraryVersions.spring"
compile "org.springframework:spring-jdbc:$libraryVersions.spring"
compile "org.springframework:spring-tx:$libraryVersions.spring"
runtime "org.springframework:spring-web:$libraryVersions.spring"
compile "commons-io:commons-io:$libraryVersions.commons_io"
// junit
testCompile "junit:junit:$libraryVersions.junit"
testCompile "org.hamcrest:hamcrest-all:$libraryVersions.hamcrest"
// arquillian
testCompile "org.jboss.arquillian.junit:arquillian-junit-container:$libraryVersions.arquillian"
testCompile "org.jboss.arquillian.protocol:arquillian-protocol-servlet:$libraryVersions.arquillian"
// shrinkwrap
testCompile "org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-javaee:$libraryVersions.shrinkwrap_descriptor"
testRuntime "org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl-javaee:$libraryVersions.shrinkwrap_descriptor"
testCompile "org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api:$libraryVersions.shrinkwrap_resolver"
testCompile "org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-gradle-embedded-archive:$libraryVersions.shrinkwrap_resolver"
// arquillian bom
testCompile "org.jboss.arquillian:arquillian-bom:$libraryVersions.arquillian"
// arquillian tx
testCompile "org.jboss.arquillian.extension:arquillian-transaction-spi:$libraryVersions.arquillian_transactions"
testCompile "org.jboss.arquillian.extension:arquillian-transaction-impl-base:$libraryVersions.arquillian_transactions"
// arquillian spring
testCompile "org.jboss.arquillian.extension:arquillian-service-integration-spring-inject:$libraryVersions.arquillian_spring"
// liquibase
runtime "org.liquibase:liquibase-core:$libraryVersions.liquibase"
runtime "com.mattbertolini:liquibase-slf4j:$libraryVersions.liquibase_slf4j"
// logging
runtime "org.slf4j:slf4j-log4j12:$libraryVersions.slf4j"
runtime "log4j:log4j:$libraryVersions.log4j"
// h2/p6spy related jars
h2 "com.h2database:h2:$libraryVersions.h2"
p6spyAll ("p6spy:p6spy:$libraryVersions.p6spy") /*{ changing=true }*/
}
//String cliPrefix = System.properties['os.name'].toLowerCase().contains('windows') ? ['cmd', '/c'] : []
// TODO alternative (more gradle like approach: https://stackoverflow.com/questions/17884861/how-to-implement-mavens-unpack-goal-in-case-of-gradle)
def File downloadFile(String url) {
File downloadDir = new File("downloads")
downloadDir.mkdirs()
// download
ant.get(src: url, dest: downloadDir.getName(), skipexisting: "true")
String name = url.substring(url.lastIndexOf("/"))
name = name.contains("?") ? name.substring(0, name.indexOf("?")) : name
new File(downloadDir.getAbsolutePath(), name)
}
// define unitTest task before apply, to enable it's manipulation in the applied build scripts
task unitTest(type: Test) {
if (System.getProperty('test.debug', 'false') == 'true') {
jvmArgs '-Xdebug',
'-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
}
if (System.getProperty('test.single', '') != '') {
includes = [System.getProperty('test.single')]
}
testLogging.showStandardStreams = true
testClassesDirs = sourceSets.test.output.classesDirs
systemProperty 'arquillian.launch', "${container}"
systemProperty 'buildDir', buildDir.getAbsolutePath()
useJUnit {
includeCategories 'com.p6spy.engine.spy.DriverTests', 'com.p6spy.engine.spy.DataSourceTests', 'com.p6spy.engine.spy.XADataSourceTests'
}
}
apply from: "./build-${container}.gradle"
// final unitTest task configuration
unitTest.classpath = project.configurations.getByName("${container}TestRuntime") + project.sourceSets.main.output + project.sourceSets.test.output
unitTest.dependsOn startContainer
unitTest.finalizedBy stopContainer
//
// h2 lifecycle
//
int h2Instance1Port=9091
int h2Instance2Port=9092
// for DB testing only
//task startH2Web(type: JavaExec) {
// // TODO fix to more gradle like syntax, see: http://gradle.1045684.n5.nabble.com/Running-a-java-program-from-Gradle-td1435769.html
// classpath configurations.h2
// main "org.h2.tools.Server"
// args "-web", "-browser"
//}
task startH2S1() {
doLast {
ant.java(
classname: "org.h2.tools.Server",
classpath: configurations.h2.asPath
)
{
arg(value: "-tcp")
arg(value: "-tcpDaemon")
arg(value: "-tcpPort")
arg(value: h2Instance1Port)
}
}
}
// gradle task does not keep h2 open on task done => going ant way (still keeping this part for future reference)
//task startH2S1(type: JavaExec) {
// // TODO fix to more gradle like syntax, see: http://gradle.1045684.n5.nabble.com/Running-a-java-program-from-Gradle-td1435769.html
// classpath configurations.testRuntime.each { it.getAbsolutePath().contains("/h2/") }
// main "org.h2.tools.Server"
// args "-tcp", "-tcpDaemon", "-tcpPort", h2Instance1Port
//}
task startH2S2() {
doLast {
ant.java(
classname: "org.h2.tools.Server",
classpath: configurations.h2.asPath
)
{
arg(value: "-tcp")
arg(value: "-tcpDaemon")
arg(value: "-tcpPort")
arg(value: h2Instance2Port)
}
}
}
task stopH2S1(type: JavaExec, dependsOn: startH2S1) {
classpath configurations.h2
main "org.h2.tools.Server"
args "-tcpShutdown" , "tcp://localhost:" + h2Instance1Port
}
task stopH2S2(type: JavaExec, dependsOn: startH2S2) {
classpath configurations.h2
main "org.h2.tools.Server"
args "-tcpShutdown", "tcp://localhost:" + h2Instance2Port
}
startContainer.dependsOn startH2S1, startH2S2
stopContainer.finalizedBy stopH2S1, stopH2S2