-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
83 lines (65 loc) · 1.83 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
version = '1.0.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
repositories {
jcenter()
mavenCentral()
}
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
mainClassName = 'org.learning.by.example.GradleDockerCI.DemoApplication'
dependencies {
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'ch.qos.logback:logback-classic:1.2.3'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-all:1.3'
}
task copySrc(type: Copy) {
group = "docker"
from "src"
into "build/docker/app/src"
}
task copyWrapperFiles(type: Copy) {
group = "docker"
from "gradlew"
from "settings.gradle"
from "build.gradle"
into "build/docker/app"
}
task copyWrapper(type: Copy){
group = "docker"
from "gradle/wrapper/gradle-wrapper.jar"
from "gradle/wrapper/gradle-wrapper.properties"
into "build/docker/app/gradle/wrapper"
}
copyWrapper.dependsOn copyWrapperFiles
task copyDockerFile(type: Copy) {
group = "docker"
from "docker"
into "build/docker"
}
def dockerFile = project.projectDir.getAbsolutePath() + "/build/docker"
def dockerName = project.name.toLowerCase() + ":" + version.toLowerCase()
task dockerBuild(type: Exec) {
workingDir project.projectDir
commandLine 'docker', 'build', '-t', dockerName, dockerFile
}
dockerBuild.dependsOn copySrc
dockerBuild.dependsOn copyWrapper
dockerBuild.dependsOn copyDockerFile
task dockerRun(type: Exec) {
group = "application"
group = "docker"
workingDir project.projectDir
commandLine 'docker', 'run', dockerName , "./gradlew", "run"
}
dockerRun.dependsOn dockerBuild
task dockerTest(type: Exec) {
group = "verification"
group = "docker"
workingDir project.projectDir
commandLine 'docker', 'run', dockerName , "./gradlew", "test"
}
dockerTest.dependsOn dockerBuild