-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
102 lines (82 loc) · 2.74 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
plugins {
id 'com.bmuschko.docker-remote-api' version '6.6.1'
}
allprojects {
group = "io.easylogic"
version = "0.0.1-SNAPSHOT"
}
subprojects {
buildscript {
ext {
aeronVersion = "1.29.0"
jlbhVersion = "1.0.1"
hdrHistogramVersion = "2.1.12"
}
repositories {
mavenCentral()
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
apply plugin: "java"
apply plugin: "com.bmuschko.docker-remote-api"
sourceCompatibility = 8
targetCompatibility = 8
repositories {
mavenCentral()
}
}
subprojects.findAll { it.name.contains("ping") }.forEach {
configure(it) {
dependencies {
implementation(project(":common"))
implementation("net.openhft:jlbh:$jlbhVersion")
implementation "org.hdrhistogram:HdrHistogram:${hdrHistogramVersion}"
}
}
}
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerRemoveImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
subprojects.findAll { it.name.contains("ping") or it.name.contains("pong") }.forEach { project ->
configure(project) {
apply plugin: 'application'
ext {
imageName = "easy-logic/$project.name"
}
dependencies {
implementation(this.project(":common"))
}
task removeImage(type: DockerRemoveImage) {
targetImageId(imageName)
onError { logger.warn(it.message) }
}
task copyDependencies(type: Copy) {
from configurations.default
into "$project.buildDir/libs"
}
task createDockerfile(type: Dockerfile) {
from "adoptopenjdk/openjdk14:alpine-jre"
copyFile("libs/*.jar", "/app/")
if (!project.name.contains("spring-boot-pong")) {
entryPoint(project.provider { ["java", "-cp", "/app/*", project.application.mainClass.get()] })
} else {
entryPoint(project.provider { ["java", "-jar", "/app/${project.jar.archiveFileName.get()}"] })
}
}
task buildImage(type: DockerBuildImage) {
// spring boot compiles everything in a flat jar, so no need to copy dependencies
if (!project.name.contains("spring-boot-pong")) {
dependsOn copyDependencies
}
dependsOn createDockerfile
inputDir = project.buildDir
dockerFile = file("$project.buildDir/docker/Dockerfile")
images.add("$imageName:latest")
}
build.dependsOn buildImage
clean.dependsOn removeImage
}
}