-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
201 lines (176 loc) Β· 7.68 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
import com.bmuschko.gradle.docker.tasks.DockerInfo
import com.bmuschko.gradle.docker.tasks.DockerVersion
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
buildscript {
ext {
springBootVersion = '2.2.5.RELEASE'
springCloudVersion = "Hoxton.RELEASE"
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/libs-snapshot' }
}
dependencies {
classpath group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: springBootVersion
classpath group: 'com.bmuschko', name: 'gradle-docker-plugin', version: '6.1.4'
classpath group: 'org.sonarsource.scanner.gradle', name: 'sonarqube-gradle-plugin', version: '2.8'
}
}
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'org.sonarqube'
sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_14
//tasks.withType(JavaCompile).each {
// it.options.compilerArgs.add('--enable-preview') // to support Java new language features;
//} // disabled to keep the app compatible with future JDK versions
bootJar {
archiveFileName = 'analog.jar'
manifest {
attributes(
"Implementation-Title": "AnaLog",
"Implementation-Version": archiveVersion.get(),
"Implementation-Vendor": "Toparvion"
)
}
}
repositories {
// mavenLocal()
mavenCentral()
maven { url 'https://repo.spring.io/libs-milestone' }
maven { url 'https://repo.spring.io/libs-snapshot' }
}
dependencies {
// Backend compile deps
// compile("org.springframework.boot:spring-boot-devtools:${springBootVersion}")
implementation platform(group: 'org.springframework.boot', name: 'spring-boot-dependencies', version: springBootVersion)
implementation platform(group: 'org.springframework.cloud', name: 'spring-cloud-dependencies', version: springCloudVersion)
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-websocket'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-context'
implementation group: 'net.bull.javamelody', name: 'javamelody-spring-boot-starter', version: '1.82.0'
implementation group: 'org.springframework.integration', name: 'spring-integration-file'
implementation group: 'org.springframework.integration', name: 'spring-integration-rmi'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
implementation group: 'net.sf.jtidy', name: 'jtidy', version: 'r938'
implementation group: 'com.github.mpkorstanje', name: 'simmetrics-core', version: '4.1.1'
implementation group: 'com.github.zafarkhaja', name: 'java-semver', version: '0.9.0'
// Frontend deps
implementation group: 'org.webjars', name: 'angularjs', version: '1.5.8'
implementation group: 'org.webjars', name: 'highlightjs', version: '9.8.0'
implementation group: 'org.webjars', name: 'jquery', version: '1.11.1'
implementation group: 'org.webjars.npm', name: 'jquery.scrollto', version: '2.1.2'
implementation group: 'org.webjars', name: 'sockjs-client', version: '1.1.2'
implementation group: 'org.webjars.npm', name: 'stomp__stompjs', version: '3.1.2'
// compile group: 'org.webjars', name: 'bootstrap', version: '3.3.7' // imported as downloaded themed version
implementation group: 'org.webjars', name: 'angular-ui-select', version: '0.19.6'
implementation group: 'org.webjars.npm', name: 'balloon-css', version: '0.5.0'
implementation group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'
runtimeOnly group: 'commons-logging', name: 'commons-logging', version: '1.2'
// Test deps
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
// JUnit family
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine'
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
}
jacocoTestReport {
reports {
xml.enabled true
}
}
sonarqube {
properties {
property "sonar.projectKey", "Toparvion_analog"
}
}
startScripts { enabled = false } // to avoid build fails because of Gradle application plugin
distributions {
boot {
contents {
into 'config/', { from 'config/' }
into 'tail-win', { from 'tail/win' }
into('') { // add empty dirs for logs and work files as per https://stackoverflow.com/a/48901794/3507435
File.createTempDir().with {
def tmpLog = new File(absolutePath, 'log')
tmpLog.mkdirs()
from(absolutePath) { includeEmptyDirs = true }
}
File.createTempDir().with {
def tmpLog = new File(absolutePath, 'work')
tmpLog.mkdirs()
from(absolutePath) { includeEmptyDirs = true }
}
}
}
}
}
//<editor-fold desc="Tasks for working with Docker images">
docker {
url = project['docker.url']
registryCredentials {
url = project['docker.registry.url']
username = project['docker.registry.username']
password = project['docker.registry.password']
email = project['docker.registry.email']
}
}
task createDockerfile(type: Dockerfile) {
description 'Generates Dockerfile for building an image of the application'
group 'docker'
from project['docker.base-image']
// all the consequent command will resolve their path relative to the following:
workingDir "/analog"
// copy main executable file of the application:
copyFile bootJar.archiveFileName.get(), bootJar.archiveFileName.get()
// copy config files:
copyFile 'config/', 'config/'
// mount dirs to store data between restarts (if needed):
// volume "/microservice/work", "/microservice/log"
environmentVariable 'APP_NAME', project.name
exposePort 8083
// conform the launch command:
entryPoint 'java'
// the command at whole will look like 'java -X... -jar analog.jar'
defaultCommand '-Xmx256M', '-XX:MaxMetaspaceSize=256M', '-XX:+HeapDumpOnOutOfMemoryError', '--enable-preview',
'-jar', "${bootJar.archiveFileName.get()}"
}
task syncImageFiles(type: Sync) {
description 'Copies to build/docker all the files for build the image'
group 'docker'
dependsOn assemble
from bootJar.archiveFile.get().getAsFile()
into createDockerfile.destFile.getAsFile().get().parentFile
into 'config/', {
from 'config/' // point the config dir apart from others
}
preserve {
include 'Dockerfile'
}
}
createDockerfile.dependsOn syncImageFiles
task buildImage(type: DockerBuildImage) {
description 'Builds and uploads Docker image of the application'
dependsOn createDockerfile
inputDir = createDockerfile.destFile.getAsFile().get().parentFile
// tags = ["${project.name}:${project.version}"]
}
task dockerVersion(type: DockerVersion) {
description 'Prints Docker version info'
}
task dockerInfo(type: DockerInfo) {
description 'Prints Docker instance info'
}
//</editor-fold>