-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
171 lines (146 loc) · 4.13 KB
/
build.gradle
File metadata and controls
171 lines (146 loc) · 4.13 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
plugins {
id 'java'
id 'maven-publish'
id 'idea'
id 'eclipse'
id 'com.diffplug.spotless' version '6.21.0'
}
allprojects {
apply plugin: 'com.diffplug.spotless'
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()
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'idea'
apply plugin: 'eclipse'
group = 'cloud.stackit'
afterEvaluate { project ->
// only apply to service sub-projects and core
if (project.path.startsWith(':services:') || project.name == "core" ) {
// 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.")
}
publishing {
publications {
maven(MavenPublication) {
artifactId = "stackit-sdk-${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/stackit-sdk-java/tree/main/services/${rootProject.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") // TODO: not clear which value must be placed here, check this when setting up publishment to Maven Central
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()
}
}
}
// 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.11.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.0'
}
}