/
build.gradle
281 lines (237 loc) · 7.08 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
plugins {
id 'java-platform'
id 'maven-publish'
id "org.sonarqube" version "3.0"
id "org.scm-manager.changelog" version "0.2.0"
id 'org.scm-manager.license' version "0.7.1"
}
changelog {
versionUrlPattern = "https://scm-manager.org/download/{0}"
}
subprojects { s ->
repositories {
mavenLocal()
maven {
url 'https://packages.scm-manager.org/repository/public/'
}
}
}
allprojects {
apply from: rootProject.file('gradle/dependencies.gradle')
}
dependencies {
constraints {
// lombok
api libraries.lombok
// jakarta
api libraries.jakartaAnnotationApi
// servlet api
api libraries.servletApi
// logging
api libraries.slf4jApi
api libraries.slf4jJcl
api libraries.logback
// injection
api libraries.guice
api libraries.guiceServlet
api libraries.guiceThrowingproviders
api libraries.guiceAssistedinject
// rest api
api libraries.jaxRs
api libraries.resteasyCore
// json
api libraries.jacksonCore
api libraries.jacksonAnnotations
// hypermedia
api libraries.edison
// dto mapping
api libraries.mapstruct
api libraries.mapstructProcessor
// events
api libraries.legman
// xml binding
api libraries.jaxbApi
api libraries.jaxbRuntime
// validation
api libraries.validator
api libraries.elApi
api libraries.elRuntime
// utils
api libraries.guava
api libraries.commonsLang
// security
api libraries.shiroCore
api libraries.ssp
api libraries.sspProcessor
api libraries.shiroUnit
// tests
api libraries.junitJupiterApi
api libraries.junitJupiterParams
api libraries.junitJupiterEngine
// junit 4 support
api libraries.junitVintageEngine
api libraries.junit
// assertions
api libraries.hamcrestCore
api libraries.hamcrestLibrary
api libraries.assertj
// mocking
api libraries.mockitoCore
api libraries.mockitoJunitJupiter
}
}
license {
header rootProject.file("LICENSE.txt")
newLine = true
ignoreNewLine = true
lineEnding = "\n"
tasks {
build {
files.from("build.gradle", "settings.gradle", "gradle.properties")
}
}
}
import org.gradle.util.VersionNumber
// set build props
project.ext {
timestamp = new Date().format('yyyyMMddHHmmSS')
revision = "git rev-parse --short HEAD".execute().text.trim()
if (project.version.contains('-SNAPSHOT')) {
isSnapshot = true
expandedVersion = project.version.replace('SNAPSHOT', timestamp)
expandedVersionWithDot = project.version.replace('-SNAPSHOT', ".${timestamp}")
dockerRepository = 'docker.io/cloudogu/scm-manager'
String snapshotVersion = revision
def buildNumber = System.getenv('BUILD_NUMBER')
if (buildNumber != null) {
snapshotVersion += "-${buildNumber}"
}
dockerTag = project.version.replace('SNAPSHOT', snapshotVersion)
} else {
isSnapshot = false
expandedVersion = project.version
expandedVersionWithDot = project.version
dockerRepository = 'docker.io/scmmanager/scm-manager'
dockerTag = project.version
}
VersionNumber v = VersionNumber.parse(project.version)
nextSnapshotVersion = "${v.major}.${v.minor}.${v.micro + 1}-SNAPSHOT"
isCI = isRunningOnCiServer()
os = os()
arch = arch()
// map signing environment variables
// this is required because of environment variables should not have a dot in the name
// but the gradle signing props are using dots
// also we use the set method, because setting props with dots works neither
if (isEnvAvailable("GPG_KEY_RING")) {
set('signing.secretKeyRingFile', System.getenv("GPG_KEY_RING"))
}
if (isEnvAvailable("GPG_KEY_ID")) {
set('signing.keyId', System.getenv("GPG_KEY_ID"))
}
if (isEnvAvailable("GPG_KEY_PASSWORD")) {
set('signing.password', System.getenv("GPG_KEY_PASSWORD"))
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId project.name
from components.javaPlatform
}
}
repositories {
maven {
String releasesRepoUrl = "https://packages.scm-manager.org/repository/releases/"
String snapshotsRepoUrl = "https://packages.scm-manager.org/repository/snapshots/"
url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl
if (project.hasProperty("packagesScmManagerUsername") && project.hasProperty("packagesScmManagerPassword")) {
credentials {
username project.property("packagesScmManagerUsername")
password project.property("packagesScmManagerPassword")
}
}
}
}
}
// determine if we run on ci
def isRunningOnCiServer() {
return isEnvAvailable("JENKINS_URL") && isEnvAvailable("BUILD_ID")
}
def isEnvAvailable(String key) {
String value = System.getenv(key)
return value != null && !value.trim().isEmpty()
}
def os() {
return System.getProperty("os.name").toLowerCase(Locale.ENGLISH)
}
def arch() {
def arch = System.getProperty("os.arch")
if ("amd64".equals(arch)) {
return "x64"
}
return arch
}
// release related tasks
task setVersion {
doLast {
if (!project.hasProperty('newVersion')) {
throw new GradleException('usage setVersion -PnewVersion=x.y.z')
}
String version = project.property('newVersion')
setNewVersion(version)
}
}
task setVersionToNextSnapshot {
doLast {
setNewVersion(nextSnapshotVersion)
}
}
task printVersion {
doLast {
println project.version
}
}
def setNewVersion(String newVersion) {
File propertiesFile = new File(project.rootDir, 'gradle.properties')
if (project.version == newVersion) {
println "project uses already version ${newVersion}"
return
}
def lines = propertiesFile.readLines('UTF-8')
def newLines = lines.collect{ line ->
if (line.trim().startsWith('version')) {
return "version = ${newVersion}"
}
return line
}
println "set version from ${project.version} to ${newVersion}"
propertiesFile.withWriter('UTF-8') {writer ->
newLines.forEach { line ->
writer.writeLine(line)
}
}
}