-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
222 lines (186 loc) · 5.64 KB
/
build.gradle
File metadata and controls
222 lines (186 loc) · 5.64 KB
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
plugins {
id 'java'
id 'signing'
id 'idea'
id 'eclipse'
id 'pmd'
id 'com.diffplug.spotless' version '8.2.1'
/* We have to use this 3rd party plugin for publishing to MavenCentral because as of AUG-2025 there is no official
* plugin which supports publishing to MavenCentral Portal. */
id "com.vanniktech.maven.publish.base" version "0.36.0"
}
allprojects {
apply plugin: 'com.diffplug.spotless'
apply plugin: 'pmd'
repositories {
mavenCentral()
}
javadoc {
options.tags = [
"http.response.details:a:Http Response Details"
]
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.release = 8 // enforce java 8 compatibility
}
spotless {
groovyGradle {
greclipse()
trimTrailingWhitespace()
indentWithTabs()
endWithNewline()
}
format 'misc', {
target '.gitattributes', '.gitignore'
trimTrailingWhitespace()
indentWithTabs()
endWithNewline()
}
java {
googleJavaFormat().aosp()
removeUnusedImports()
importOrder()
formatAnnotations()
trimTrailingWhitespace()
indentWithTabs()
endWithNewline()
}
}
pmd {
consoleOutput = true
toolVersion = "7.20.0"
// This tells PMD to use your custom ruleset file.
ruleSetFiles = rootProject.files("config/pmd/pmd-ruleset.xml")
// This is important: it prevents PMD from using its default rules.
ruleSets = []
}
}
def configureMavenCentralPublishing(Project project) {
project.plugins.withId('com.vanniktech.maven.publish.base') {
project.mavenPublishing {
publishToMavenCentral(true) // publish automatically after upload to Maven Central
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
group = 'cloud.stackit.sdk'
// only apply to service sub-projects and core
if (project.path.startsWith(':services:') || project.name == "core" ) {
apply plugin: 'signing'
apply plugin: 'com.vanniktech.maven.publish.base'
// override the version of each service with the ones obtained from the VERSION files
def versionFile = project.file("VERSION")
if (versionFile.exists()) {
try {
version = versionFile.text.trim()
} catch (IOException e) {
version = 'SNAPSHOT'
logger.error("Could not read VERSION file for project '${project.path}': ${e.message}")
}
} else {
version = 'SNAPSHOT'
logger.warn("VERSION file not found in project '${project.path}'. Skipping version setting.")
}
tasks.register('lintProjectVersion', VersionCheckTask) {}
java {
withSourcesJar()
withJavadocJar()
}
// don't fail on missing javadoc strings
tasks.withType(Javadoc).configureEach {
options.addStringOption('Xdoclint:none', '-quiet')
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = "${project.name}"
from components.java
pom {
name.set(project.name)
description.set("STACKIT Java SDK for the ${project.name} service")
url.set("https://github.com/stackitcloud/${rootProject.name}/tree/main/services/${project.name}")
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("stackitcloud")
name.set("STACKIT Developer Tools")
email.set("developer-tools@stackit.cloud")
}
}
scm {
connection.set("scm:git:git://github.com/stackitcloud/${rootProject.name}.git")
developerConnection.set("scm:git:ssh://github.com/stackitcloud/${rootProject.name}.git")
url.set("https://github.com/stackitcloud/${rootProject.name}")
}
}
}
}
repositories {
mavenLocal()
}
}
signing {
required {
// signing is only required if the artifacts are to be published to Maven Central
gradle.taskGraph.hasTask(":services:${project.name}:publishToMavenCentral") || gradle.taskGraph.hasTask(":${project.name}:publishToMavenCentral")
}
def signingKey = System.getenv("GPG_SIGNING_KEY") ?: findProperty("signingKey")
def signingPassword = System.getenv("GPG_SIGNING_PASSWORD") ?: findProperty("signingPassword")
useInMemoryPgpKeys(signingKey as String, signingPassword as String)
sign publishing.publications.mavenJava
}
configureMavenCentralPublishing(project)
}
// only apply to example sub-projects
if (project.path.startsWith(':examples:')) {
if (!project.hasProperty('mainClassName')) {
logger.warn("'mainClassName' property not defined for subproject '${project.path}'. Skipping execution of this task.")
}
tasks.register('execute', JavaExec) {
if (!project.hasProperty('mainClassName')) {
doLast {
logger.warn("'mainClassName' property not defined for subproject '${project.path}'. Skipping execution of this task.")
}
enabled = false // Disable the task if no main class is specified
return
}
mainClass = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
}
}
tasks.withType(Test).configureEach {
// Enable JUnit 5 (Gradle 4.6+).
useJUnitPlatform()
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
// Show test results.
testLogging {
events "passed", "skipped", "failed"
}
}
dependencies {
if (project.path != ':core') {
// prevent circular dependency
implementation project(':core')
}
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.14.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.14.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.14.3'
}
}