Tobias Gesellchen
(it's generally better to know one's dependencies)
def dependencyVersions = [
'javax.servlet:javax.servlet-api:3.0.1',
'log4j:log4j:1.2.17'
]
configurations {
all*.exclude module: 'jaxb-xjc'
all.resolutionStrategy {
failOnVersionConflict()
force dependencyVersions.collect { it }
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.springframework') {
details.useVersion '3.2.4.RELEASE'
}
}
}
}
// root build.gradle
subprojects {
ext.libraries = [
javax: [
validation: [
'javax.validation:validation-api:1.1.0.Final',
'javax.validation:validation-api:1.1.0.Final:sources'
]
],
gwt : [
user: dependencies.create('com.google.gwt:gwt-user:2.6.0') {
transitive = false
}
]
]
}
// child build.gradle
dependencies {
compile libraries.javax.validation
provided libraries.gwt.user
}
apply plugin: 'groovy'
sourceSets.main.java.srcDirs = []
sourceSets.main.groovy.srcDirs += ["src/main/java"]
sourceSets.test.java.srcDirs = []
sourceSets.test.groovy.srcDirs += ["src/test/java"]
task testng(type: Test) {
useTestNG()
}
check.dependsOn testng
task aggregateTestReports(type: TestReport) {
destinationDir = test.reports.html.destination
reportOn test, testng
}
aggregateTestReports.mustRunAfter testng
check.dependsOn aggregateTestReports
tasks.withType(Test) {
systemProperty 'db.url', System.getProperty('db.url', 'http://db.example.com/test')
}
publishing {
publications {
mavenJava(MavenPublication) {
version new SimpleDateFormat('yyyyMMddHHmmss').format(new Date())
from components.java
}
}
}
configurations {
contracttests
}
afterEvaluate {
// TeamCity build artifact from publish build goal
def appVersion = new File('version.txt').text.trim()
def contracttestDep = dependencies.create("de.hypoport:app-contracttests:${appVersion}") {
transitive = false
}
dependencies.add 'contracttests', contracttestDep
def testRuntimeDep = dependencies.create("de.hypoport:app-contracttests:${appVersion}")
dependencies.add 'testRuntime', testRuntimeDep
}
def contracttestsDirectory = "${buildDir}/contracttests"
task unzipContracttests(type: Copy) {
from {
zipTree(configurations.contracttests.singleFile)
}
into {
contracttestsDirectory
}
}
task contracttests(type: Test) {
dependsOn unzipContracttests
testClassesDir file(contracttestsDirectory)
}
"docker pull http://docker-registry/kreditsmart-base".execute()
"docker build -t kreditsmart --rm .".execute()
"docker tag kreditsmart http://docker-registry/kreditsmart:${version}".execute()
"docker push http://docker-registry/kreditsmart".execute()
"docker rmi http://docker-registry/kreditsmart:${version}".execute()
"docker pull baseimage".execute()
"docker build .".execute()
"docker tag image ${version}".execute()
"docker push image.execute()
"docker rmi image".execute()
"docker -H tcp://app-server:2375 pull ...".execute()
"docker -H ... stop ...".execute()
"docker -H ... rm ...".execute()
"docker -H ... run -d ...".execute()
"docker -H ... ps".execute()
"docker -H tcp://app-server:2375 pull http://docker-registry/kreditsmart:${version}".execute()
def prevImageId = "docker -H tcp://app-server:2375 inspect --format={{.Image}} kreditsmart-${selectedStage}".execute()
"docker -H tcp://app-server:2375 stop kreditsmart-${selectedStage}".execute()
"docker -H tcp://app-server:2375 rm kreditsmart-${selectedStage}".execute()
"docker -H tcp://app-server:2375 rmi ${prevImageId}".execute()
"""\
docker -H tcp://app-server:2375 run -d --name=kreditsmart-${selectedStage} \
-v /logs/${selectedStage}:/opt/kreditsmart-backend/logs:rw -p ${publicPortBackend}:8090 \
-v /logs/${selectedStage}:/opt/kreditsmart-frontend/logs:rw -p ${publicPortFrontend}:8080 \
${serverEnvironment.run_env} http://docker-registry/kreditsmart:${version} \
""".execute()
["sh", "-c", "docker -H tcp://app-server:2375 images | grep none | awk '{print \$3}' | xargs docker -H tcp://${hostname} rmi"].execute()
"docker -H tcp://app-server:2375 ps".execute()