forked from SVWS-NRW/SVWS-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
313 lines (257 loc) · 10 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
import org.gradle.internal.os.OperatingSystem
plugins {
// TODO Support JPMS-Modules
// id "de.jjohannes.extra-java-module-info" version "0.9" apply false
id 'com.github.jk1.dependency-license-report' version '2.1'
id 'org.sonarqube' version '4.3.0.3225'
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
id 'svws.gradle.node.plugin'
}
def config = new groovy.json.JsonSlurper().parseText(file("buildconfig.json").text)
println "Version " + config.project.version
def gitHASH = null;
if (file(".git/HEAD").exists()) {
def gitHEADFileString = file(".git/HEAD").text
if (gitHEADFileString.trim().length() == 40) {
gitHASH = gitHEADFileString.trim()
} else {
def gitHEADRefParts = gitHEADFileString.split(":");
if ((gitHEADRefParts.length == 2) && (gitHEADRefParts[0].trim().equals("ref"))) {
if (file(".git/" + gitHEADRefParts[1].trim()).exists()) {
def gitHEADHASHFileString = file(".git/" + gitHEADRefParts[1].trim()).text
if (gitHEADHASHFileString.trim().length() == 40)
gitHASH = gitHEADHASHFileString.trim()
} else if (file(".git/packed-refs").exists()) {
def gitPackedRefsFileString = file(".git/packed-refs").text
gitPackedRefsFileString.eachLine {
String[] tokens = it.split(" ");
if ((tokens.length == 2) && (tokens[1].trim().equals(gitHEADRefParts[1].trim())))
gitHASH = tokens[0].trim()
}
}
}
}
}
println "Git-Hash: " + gitHASH
String osName = OperatingSystem.current().getName();
String osVersion = OperatingSystem.current().getVersion();
String os = OperatingSystem.current().isMacOsX();
println "*** OS-Version: $osName $osVersion was detected. (MacOS: $os)"
println "*** Gradle Version: $gradle.gradleVersion"
int cores = Runtime.getRuntime().availableProcessors();
println "*** Number of CPU-Cores: $cores"
double memFree = Runtime.getRuntime().freeMemory() / 1000000.0;
double memUsed = Runtime.getRuntime().totalMemory() / 1000000.0;
double memMax = Runtime.getRuntime().maxMemory() / 1000000.0;
println "*** Memory (free): %.0fM".formatted(memFree)
println "*** Memory (used): %.0fM".formatted(memUsed)
println "*** Memory (max): %.0fM".formatted(memMax)
wrapper {
description "Regenerates the Gradle Wrapper files"
gradleVersion = '8.3'
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}
allprojects {
apply plugin: 'svws.gradle.javalib.plugin'
apply plugin: 'svws.gradle.svwsmavenrepo.plugin'
apply plugin: 'svws.gradle.svwseclipse.plugin'
apply plugin: 'org.sonarqube'
apply plugin: 'checkstyle'
// TODO Support JPMS-Modules
// apply plugin: 'de.jjohannes.extra-java-module-info'
version = config.project.version
project.ext.latestRelease = config.project.version
group = 'de.svws-nrw'
svwsmavenrepo {
//nexusMavenCentralProxyRepositoryUrl = 'https://artifactory.svws-nrw.de/repository/maven-central'
githubMavenPackagesUrl = 'https://maven.pkg.github.com/SVWS-NRW/SVWS-Server'
}
java {
withJavadocJar()
withSourcesJar()
}
javadoc {
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
options.docEncoding = 'UTF-8'
options.addStringOption('Xmaxerrs', '10000')
options.addStringOption('Xmaxwarns', '10000')
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
options.addStringOption('Xdoclint:none', '-quiet')
}
}
sonarqube {
properties {
property "sonar.sourceEncoding", "UTF-8"
}
}
// create javadoc task for test code
task testJavadoc(type: Javadoc) {
group = 'documentation'
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
options.docEncoding = 'UTF-8'
options.addStringOption('Xmaxerrs', '10000')
options.addStringOption('Xmaxwarns', '10000')
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
options.addStringOption('Xdoclint:none', '-quiet')
}
source = sourceSets.test.allJava
classpath = sourceSets.test.compileClasspath
destinationDir = file("${buildDir}/docs/testjavadoc")
}
javadoc.dependsOn testJavadoc
/*
eclipse {
project {
natures 'net.sf.eclipsecs.core.CheckstyleNature'
buildCommand 'net.sf.eclipsecs.core.CheckstyleBuilder'
}
}
*/
/* TODO Support JPMS-Modules
plugins.withType(JavaPlugin).configureEach {
java {
modularity.inferModulePath = true
}
}
*/
test {
useJUnitPlatform()
}
configurations {
extendedDefault {
extendsFrom configurations.default
canBeResolved = true
}
}
task printDependencies {
group = 'build'
doLast {
println "Dependencies:"
configurations.extendedDefault.each { println it }
}
}
}
subprojects {
// Publishing-Plugin für alle Module aktivieren (mit Ausnahme des Moduls 'gradle-build-src')
if (it.name != 'gradle-build-src') {
apply plugin: 'svws.gradle.svwsmavenpublish.plugin'
svwsmavenpublish {
nexusSnapshotRepositoryUrl = 'https://artifactory.svws-nrw.de/repository/svws-maven-snapshots'
nexusReleasesRepositoryUrl = 'https://artifactory.svws-nrw.de/repository/svws-maven-releases'
githubReleasesRepositoryUrl = 'https://maven.pkg.github.com/SVWS-NRW/SVWS-Server'
}
}
}
println "Prüfe die Projekt-Version und passe diese ggf. an:"
fileTree(dir: './', include: '**/package.json', exclude: '**/node_modules/**').files.findAll {
def f = new File("" + it)
def text = f.text
def updated = text.replaceAll('"version": "[^"]*"', '"version": "' + config.project.version + '"');
if (text.equals(updated)) {
println " " + it + " UP-TO-DATE"
} else {
println " " + it + " aktualisiere auf Version " + config.project.version
f.withWriter { w -> w << updated }
}
}
def fileVersionTS = new File("${rootDir}/svws-webclient/client/version.ts")
fileVersionTS.withWriter { w -> w << 'export const version = "' + config.project.version + '"' }
def fileVersionTSAdminClient = new File("${rootDir}/svws-webclient/admin/version.ts")
fileVersionTSAdminClient.withWriter { w -> w << 'export const version = "' + config.project.version + '"' }
def fileVersionTSLaufbahnplanung = new File("${rootDir}/svws-webclient/laufbahnplanung/version.ts")
fileVersionTSLaufbahnplanung.withWriter { w -> w << 'export const version = "' + config.project.version + '"' }
def tsGitHashStr = (gitHASH == null) ? 'null' : '"' + gitHASH + '"'
def fileGithashTS = new File("${rootDir}/svws-webclient/client/githash.ts")
fileGithashTS.withWriter { w -> w << 'export const githash = ' + tsGitHashStr }
def fileGithashTSAdminClient = new File("${rootDir}/svws-webclient/admin/githash.ts")
fileGithashTSAdminClient.withWriter { w -> w << 'export const githash = ' + tsGitHashStr }
def fileGithashTSLaufbahnplanung = new File("${rootDir}/svws-webclient/laufbahnplanung/githash.ts")
fileGithashTSLaufbahnplanung.withWriter { w -> w << 'export const githash = ' + tsGitHashStr }
task npmPrepare(type: NpmInstall) {
group "build"
inputs.files fileTree(dir: './', include: 'package.json')
doNotTrackState("")
}
task rebuild(type: GradleBuild) {
tasks = ['clean', 'build']
group "build"
}
task wipe() {
dependsOn nodeWipe
group "build"
}
task assembleServer() {
dependsOn(':svws-server-app:assemble')
group "build"
}
task buildServer() {
dependsOn(':svws-server-app:build')
group "build"
}
task assembleTS() {
dependsOn(':svws-webclient:client:assemble')
group "build"
}
task buildTS() {
dependsOn(':svws-webclient:client:build')
group "build"
}
task publishReleaseAllAndCloseSonatype(type: GradleBuild) {
tasks = ['publishAllPublicationsToSonatypeRepository', 'closeAndReleaseSonatypeStagingRepository', 'publishReleaseAll']
group "publishing"
description 'Publish ins Sonatype Staging, im Anschluss Release nach Maven Central und Schließen des Staging. Danach Release zu anderen Repositories'
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = getOssrhActor()
password = getOssrhToken()
}
}
}
task allJavadoc(type: Javadoc) {
project.subprojects.each {
if (it.plugins.hasPlugin('java')) {
source += it.java.sourceSets.main.allJava
classpath += it.java.sourceSets.main.compileClasspath
}
}
destinationDir = file("${buildDir}/docs/javadoc-all")
}
import com.github.jk1.license.render.*
import com.github.jk1.license.importer.*
licenseReport {
// Set output directory for the report data.
// Defaults to ${project.buildDir}/reports/dependency-license.
outputDir = "$projectDir/build/licenses"
// Select projects to examine for dependencies.
// Defaults to current project and all its subprojects
projects = [project] + project.subprojects
// Adjust the configurations to fetch dependencies, e.g. for Android projects. Default is 'runtimeClasspath'
// configurations = ['implementation']
// Use 'ALL' to dynamically resolve all configurations:
// configurations = ALL
configurations = ['runtimeClasspath']
// List the groups ids to exclude from dependency report. Supports regular expressions.
// For finer granularity, see: excludes.
excludeGroups = ['de.svws_nrw.server']
// List the ids (in module:name format) to exclude from dependency report. Supports regular expressions.
// By default excludes is empty.
excludes = ['moduleGroup:moduleName']
// Don't include artifacts of project's own group into the report
excludeOwnGroup = true
// Set custom report renderer, implementing ReportRenderer.
// Yes, you can write your own to support any format necessary.
renderers = [new XmlReportRenderer('third-party-libs.xml', 'Back-End Libraries')]
// Set importers to import any external dependency information, i.e. from npm.
// Custom importer should implement DependencyDataImporter interface.
// importers = [new XmlReportImporter('Frontend dependencies', file(frontend_libs.xml))]
// This is for the allowed-licenses-file in checkLicense Task
allowedLicensesFile = new File("$projectDir/allowed-licenses.json")
}