-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
135 lines (116 loc) · 3.64 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
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.1'
id 'com.palantir.docker' version '0.13.0'
id 'com.github.ben-manes.versions' version '0.15.0'
}
description = 'Add a simple description of the service.' // TODO: replace with correct description
version = System.getenv('VERSION_NUMBER') ?: '0.0.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
projectName = 'service-name' // TODO: replace with the correct service name
projectPort = System.getenv('PORT') ?: '8080'
commitHash = System.getenv('COMMIT_HASH') ?: 'local'
dropwizardVersion = '1.1.1'
}
repositories {
jcenter()
mavenCentral()
}
sourceSets {
testUtils {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/test/utils')
}
}
unitTest {
java {
compileClasspath += main.output + test.output + testUtils.output
runtimeClasspath += main.output + test.output + testUtils.output
srcDir file('src/test/unit')
}
}
integrationTest {
java {
compileClasspath += main.output + test.output + testUtils.output
runtimeClasspath += main.output + test.output + testUtils.output
srcDir file('src/test/integration')
}
resources.srcDir file('src/test/resources')
}
}
configurations {
testUtilsCompile.extendsFrom testCompile
testUtilsRuntime.extendsFrom testRuntime
unitTestCompile.extendsFrom testCompile
unitTestRuntime.extendsFrom testRuntime
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
compile 'io.dropwizard:dropwizard-core:' + dropwizardVersion
compile 'io.dropwizard:dropwizard-client:' + dropwizardVersion
compile 'io.dropwizard.metrics:metrics-core:3.2.2'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.8.8'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.8'
compile 'com.jcabi:jcabi-manifests:1.1'
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.8.0'
testCompile 'org.mockito:mockito-core:2.8.47'
testCompile 'io.dropwizard:dropwizard-testing:' + dropwizardVersion
testCompile 'com.jayway.jsonpath:json-path:2.4.0'
testCompile 'com.github.tomakehurst:wiremock:2.7.1'
}
applicationDefaultJvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5006"]
mainClassName = "uk.co.example.serviceName.ServiceName" // TODO: replace with the correct main class
run {
args 'server', 'src/config/app_config.yml'
environment 'PORT', projectPort
}
jar {
manifest {
attributes([
'Commit-Hash' : commitHash,
'Version-Number': project.version
])
}
}
shadowJar {
baseName projectName
mergeServiceFiles()
}
docker {
name "${projectName}:${version}"
tags(version, 'latest')
files tasks.shadowJar.outputs, 'src/config/app_config.yml'
buildArgs([
'PORT' : projectPort,
'JAR_NAME' : "${projectName}-${version}-all.jar",
'CONFIG_NAME': 'app_config.yml'
])
labels([
'description': description,
'version' : version,
'commit-hash': commitHash
])
}
docker.dependsOn shadowJar
task unitTest(type: Test) {
testClassesDirs = sourceSets.unitTest.output.classesDirs
classpath = sourceSets.unitTest.runtimeClasspath
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
test.dependsOn unitTest
test.dependsOn integrationTest
integrationTest.mustRunAfter unitTest