-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle
154 lines (128 loc) · 3.82 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
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
sourceCompatibility = 8
def mainClass='de.lisaplus.atlas.DoCodeGen'
project.group = 'de.lisaplus.tools'
project.version = '0.13.2'
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc.destinationDir
}
repositories {
mavenCentral()
}
artifacts {
archives jar
}
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'com.beust', name: 'jcommander', version: '1.69'
compile 'org.apache.commons:commons-lang3:3.3'
compile 'org.codehaus.groovy:groovy-all:2.5.7'
compile group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '3.0.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
clean {
delete "${buildDir}/release"
}
task dependenciesToLibDir(type: Copy) {
into "$buildDir/release/lib"
from configurations.runtime
}
task buildRelease (type: Copy) {
println 'buildRelease start ...'
outputs.upToDateWhen { false }
copy {
from "${project.rootDir}/src/main/resources/bin"
into "${buildDir}/release"
}
copy {
from "${project.rootDir}/src/main/resources/conf"
into "${buildDir}/release/conf"
}
into "${buildDir}/release/lib"
from "${buildDir}/libs"
println 'buildRelease end ...'
}
task zipRelease (type: Zip) {
doLast {
println 'zipRelease'
from "${buildDir}/release"
include '*'
include '*/*'
archiveName "$releaseArchiveName"
destinationDir(file("${buildDir}"))
}
}
task myRun (type: JavaExec, dependsOn: classes){
if(project.hasProperty('myArgs')){
args(myArgs.split(','))
}
if (project.hasProperty('DEBUG')) {
jvmArgs '-Xdebug',
'-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009'
}
main = mainClass
classpath = sourceSets.main.runtimeClasspath
}
dependenciesToLibDir.dependsOn jar
buildRelease.dependsOn dependenciesToLibDir
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration_test/java')
}
/* not needed this time
resources.srcDir file('src/integration-test/resources')
*/
}
}
task integrationTest(type: Test) {
doFirst {
// that's the place to init integration tests
}
doLast {
// that's the place to tidy up test integration environment
}
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
task buildDockerImage {
outputs.upToDateWhen { false }
doLast {
def imageName=['bash','docker/bin/image_conf.sh'].execute().text.trim()
println "create image: $imageName ..."
def cmd = ['docker', 'build', '-t', imageName,'.']
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(20000)
if (serr.size()>0) {
println "err> $serr"
}
else {
println "... created"
}
}
}
buildRelease.dependsOn assemble
buildDockerImage.dependsOn buildRelease
check.dependsOn integrationTest
integrationTest.mustRunAfter test
buildRelease.dependsOn test
zipRelease.dependsOn buildRelease