-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
202 lines (175 loc) · 7.02 KB
/
build.gradle
File metadata and controls
202 lines (175 loc) · 7.02 KB
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
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: "sonar-runner"
apply plugin: 'maven-publish'
version = 0.1
group = 'com.soldev'
task wrapper(type: Wrapper) {
gradleVersion = "2.2.1"
}
repositories {
mavenCentral()
}
sourceSets {
systemTest
performanceTest
integrationTest
resources
}
configurations {
systemTestWar
}
dependencies {
compile localGroovy()
compile 'asm:asm:3.3.1'
compile 'com.sun.jersey:jersey-bundle:1.17.1'
compile "joda-time:joda-time:2.2"
compile 'org.json:json:20131018'
compile 'org.hibernate:hibernate-core:4.3.6.Final'
compile 'postgresql:postgresql:9.0-801.jdbc4'
//needed to make jodatime work with hibernate!
compile 'org.jadira.usertype:usertype.jodatime:2.0.1'
compile(group: 'log4j', name: 'log4j', version: '1.2.17')
compile(group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.6') // van nexus apd
compile(group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5')
testCompile "org.testng:testng:6.3.1"
testCompile "junit:junit:4.9"
integrationTestCompile configurations.testCompile
integrationTestRuntime configurations.testRuntime
systemTestCompile configurations.testCompile
systemTestRuntime configurations.testRuntime
performanceTestCompile configurations.testCompile
performanceTestRuntime configurations.testRuntime
}
jacocoTestReport {
reports {
html.enabled true
}
}
task "createProjectStructure" << {
sourceSets*.java.srcDirs*.each { it.mkdirs() }
sourceSets*.groovy.srcDirs*.each { it.mkdirs() }
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
}
artifacts{
archives war
}
tasks.withType(Exec) {
environment 'DOCKER_CERT_PATH', DOCKER_CERT_PATH
environment 'DOCKER_TLS_VERIFY', DOCKER_TLS_VERIFY
environment 'DOCKER_HOST', DOCKER_HOST
}
task stopAndRemoveOldDockerContainer(type: Exec) {
def curUser = System.getenv('USER')
def dockerCommand = new File("/tmp/dockerCommand${curUser}.sh")
dockerCommand.write('id=($(/usr/local/bin/docker ps -a | grep datamanager))\n\
if [ X${id} != X"" ]; then\n\
echo "removing:$id images"\n\
/usr/local/bin/docker rm -f $id\n\
echo "done removing $1"\n\
else\n\
echo "no images running"\n\
fi')
commandLine 'sh', "/tmp/dockerCommand${curUser}.sh"
}
task copyDockerFiles(type: Copy) {
//this makes sure we don't accidentally use the wrong war file.
from "docker"
into 'build/docker'
}
task getLatestReleasedWar(type: Exec, dependsOn: copyDockerFiles) {
commandLine "${projectDir}/gradlew", '-b', 'getLatestReleasedWar.gradle', 'getLatestRelease'
}
task copyJarDocker(type: Copy, dependsOn: ["war", "jar", "getLatestReleasedWar"]) {
from "build/libs"
into 'build/docker'
}
task copyJarSystemTestDocker(type: Exec, dependsOn: "copyDockerFiles") {
commandLine "${projectDir}/gradlew", '-b', 'getWarPublishWar.gradle', 'getLatestSnapshot'
}
task buildDockerContainer(type: Exec, dependsOn: "copyJarDocker") {
workingDir 'build/docker/'
commandLine '/usr/local/bin/docker', 'build', '-t', "datamanager:${version}", '.'
}
task buildDockerSystemTestContainer(type: Exec, dependsOn: "copyJarSystemTestDocker") {
workingDir 'build/docker/'
commandLine '/usr/local/bin/docker', 'build', '-t', "datamanagersystem:${version}", '.'
}
task runDockerContainer(type: Exec, dependsOn: "buildDockerContainer") {
// to expose port to outside world: '-p', '10022:22',
commandLine '/usr/local/bin/docker', 'run', '-p', '3232:8080', '-p', '3222:22', '--name', "datamanager-run-${version}", '-d', '-t', "datamanager:${version}"
}
task stopAndRemoveOldDockerSystemTestContainer(type: Exec) {
def curUser = System.getenv('USER')
def dockerCommand = new File("/tmp/dockerCommandSystemTest${curUser}.sh")
dockerCommand.write('id=($(/usr/local/bin/docker ps -a | grep datamanager-system-test))\n\
if [ X${id} != X"" ]; then\n\
echo "removing:$id images"\n\
/usr/local/bin/docker rm -f $id\n\
echo "done removing $1"\n\
else\n\
echo "no images running"\n\
fi')
commandLine 'sh', "/tmp/dockerCommandSystemTest${curUser}.sh"
}
task runDockerSystemTestContainer(type: Exec, dependsOn: ["buildDockerSystemTestContainer","stopAndRemoveOldDockerSystemTestContainer"]) {
// to expose port to outside world: '-p', '10022:22',
commandLine '/usr/local/bin/docker', 'run', '-p', '4242:8080', '--name', "datamanager-system-test-run-${version}", '-d','-t', "datamanagersystem:${version}"
}
task systemTest(type: Test, dependsOn: runDockerSystemTestContainer) {
systemProperties['SYSTEM_TEST_HOST'] = SYSTEM_TEST_HOST ?: "localhost"
testClassesDir = sourceSets.systemTest.output.classesDir
classpath = sourceSets.systemTest.runtimeClasspath
reports.junitXml.destination = file("${reporting.baseDir}/systemTest")
reports.html.destination = file("${reporting.baseDir}/systemTest")
}
task releaseDataManger(type: Exec, dependsOn: systemTest) {
commandLine "${projectDir}/gradlew", '-b', 'getWarPublishWar.gradle', 'publish'
}
task performanceTest(type: Test) {
testClassesDir = sourceSets.performanceTest.output.classesDir
classpath = sourceSets.performanceTest.runtimeClasspath
reports.junitXml.destination = file("${reporting.baseDir}/performanceTest")
reports.html.destination = file("${reporting.baseDir}/performanceTest")
}
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
reports.junitXml.destination = file("${reporting.baseDir}/integrationTest")
reports.html.destination = file("${reporting.baseDir}/integrationTest")
}
task liveTestGroup(dependsOn: ['systemTest', 'performanceTest', 'integrationTest'])
publishing {
publications {
maven(MavenPublication){
from components.web
groupId = project.group
version = project.version + '-SNAPSHOT'
}
}
repositories {
maven {
url "${artifactory_uploadContextUrl}/${ExternalRepo}/libs-snapshot-local"
credentials {
logger.quiet ("url = ${artifactory_uploadContextUrl}/${ExternalRepo}/libs-snapshot-local")
logger.quiet("artifactory username = ${System.getenv().artifactory_push_user}")
username = "${System.getenv().artifactory_push_user}"
password = "${System.getenv().artifactory_push_password}"
}
}
}
}
sonarRunner {
sonarProperties {
property "sonar.jacoco.reportPath", "$buildDir/jacoco/test.exec"
property "sonar.jdbc.driverClassName", "com.postgresql.jdbc.Driver"
property "sonar.host.url", System.getenv("SonarUrl") ?: "dummy"
property "sonar.jdbc.url", System.getenv("SonarDB") ?: "dummy"
property "sonar.jdbc.username", System.getenv("SonarUser") ?: "dummy"
property "sonar.jdbc.password", System.getenv("SonarPass") ?: "dummy"
}
}