-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
205 lines (157 loc) · 6.08 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
version = readVersion()
apply from: "gradle/vertx.gradle"
apply plugin: "jacoco"
/*
Usage:
./gradlew task_name
(or gradlew.bat task_name if you have the misfortune to have to use Windows)
If no task name is specified then the default task 'assemble' is run
Task names are:
idea - generate a skeleton IntelliJ IDEA project
eclipse - generate a skeleton Eclipse IDE project
assemble - builds the outputs, by default this is the module zip file. It can also include a jar file if produceJar
in gradle.properties is set to true. Outputs are created in build/libs.
if pullInDeps in gradle.properties is set to 'true' then the modules dependencies will be
automatically pulled into a nested mods directory inside the module during the build
copyMod - builds and copies the module to the local 'mods' directory so you can execute vertx runmod (etc)
directly from the command line
modZip - creates the module zip into build/libs
clean - cleans everything up
test - runs the tests. An nice html test report is created in build/reports/tests (index.html)
runMod - runs the module. This is similar to executing vertx runmod from the command line except that it does
not use the version of Vert.x installed and on the PATH to run it. Instead it uses the version of Vert.x
that the module was compiled and tested against.
pullInDeps - pulls in all dependencies of the module into a nested module directory
uploadArchives - upload the module zip file (and jar if one has been created) to Nexus. You will need to
configure sonatypeUsername and sonatypePassword in ~/.gradle/gradle.properties.
install - install any jars produced to the local Maven repository (.m2)
*/
dependencies {
/*
Add your module jar dependencies here
E.g.
compile "com.foo:foo-lib:1.0.1" - for compile time deps - this will end up in your module too!
testCompile "com.foo:foo-lib:1.0.1" - for test time deps
provided "com.foo:foo-lib:1.0.1" - if you DON'T want it to be packaged in the module zip
*/
// If you're creating Groovy compiled verticles you may need the following dependencies
provided "org.codehaus.groovy:groovy-all:$groovyVersion"
provided "io.vertx:lang-groovy:$groovyLangModVersion@jar"
}
test {
}
jacoco {
toolVersion = "0.7.1.201405082137"
}
String readVersion() {
def versionFile = file('version.properties')
def env = System.getenv()
def versionSuffix = (env.PIPE_FLOW_NUMBER != null) ? ".$env.PIPE_FLOW_NUMBER" : '-SNAPSHOT'
Properties versionProps = new Properties()
versionFile.withInputStream { stream ->
versionProps.load(stream)
}
return versionProps.APP_VERSION_PREFIX + versionSuffix
}
task versionNumber << {
println "version: $version"
}
/*
If you're uploading stuff to Maven, Gradle needs to generate a POM.
Please edit the details below.
*/
def configurePom(def pom) {
pom.project {
name rootProject.name
description 'CH OPEN Workshoptage 2014 - Continuous Delivery - Beispiel Projekt - issumy'
inceptionYear '2014'
packaging 'jar'
url 'https://github.com/ollin/cd-ws-issumy'
developers {
developer {
id 'ollin'
name 'Oliver Nautsch'
email '[email protected]'
}
}
scm {
url 'https://github.com/ollin/cd-ws-issumy.git'
}
licenses {
license {
name 'The MIT License (MIT)'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}
properties {
setProperty('project.build.sourceEncoding', 'UTF8')
}
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://localhost:8181/nexus/content/repositories/releases/") {
authentication(
userName: "deployment",
password: "deployment9"
)
}
snapshotRepository(url: "http://localhost:8181/nexus/content/repositories/snapshots/") {
authentication(
userName: "deployment",
password: "deployment9"
)
}
}
}
}
task prepareModZipForDocker (type: Copy) {
from modZip
into 'build/docker'
}
task createDockerfile << {
def dockerFile = 'build/docker/Dockerfile'
def oldDockerFile = new File(dockerFile)
if (oldDockerFile.exists()) {
oldDockerFile.delete();
}
def newDockerFile = new File(dockerFile)
newDockerFile.createNewFile();
newDockerFile.withWriter { out ->
out.writeLine("FROM ollin/vertx")
out.writeLine("MAINTAINER Oliver Nautsch <[email protected]>")
out.writeLine("")
out.writeLine("VOLUME /home/issumy")
out.writeLine("ADD $modZip.archiveName /home/issumy/$modZip.archiveName")
out.writeLine("EXPOSE 8080")
out.writeLine("")
out.writeLine("WORKDIR /home/issumy")
out.writeLine("CMD [\"runzip\", \"$modZip.archiveName\"]")
}
}
createDockerfile.dependsOn prepareModZipForDocker
task createDockerImage (type: Exec) {
workingDir 'build/docker'
commandLine 'sudo', 'docker', 'build', '-t', "inventage/issumy:$version", '.'
}
createDockerImage.dependsOn createDockerfile, prepareModZipForDocker
build.dependsOn createDockerImage
task tagDockerImageLatest (type: Exec) {
commandLine 'sudo', 'docker', 'tag', "inventage/issumy:$version", "localhost:5000/inventage/issumy:latest"
}
tagDockerImageLatest.dependsOn createDockerImage
task pushDockerImageLatest (type: Exec) {
commandLine 'sudo', 'docker', 'push', "localhost:5000/inventage/issumy:latest"
}
pushDockerImageLatest.dependsOn tagDockerImageLatest
task tagDockerImageVersion (type: Exec) {
commandLine 'sudo', 'docker', 'tag', "inventage/issumy:$version", "localhost:5000/inventage/issumy:$version"
}
tagDockerImageVersion.dependsOn createDockerImage
task pushDockerImageVersion (type: Exec) {
commandLine 'sudo', 'docker', 'push', "localhost:5000/inventage/issumy:$version"
}
pushDockerImageVersion.dependsOn tagDockerImageVersion
//uploadArchives.dependsOn pushDockerImageVersion, pushDockerImageLatest