-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
225 lines (186 loc) · 6.6 KB
/
build.gradle.kts
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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
signing
`maven-publish`
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kotlin.noarg)
alias(libs.plugins.springboot) apply false
}
allprojects {
group = "net.sunshow.nxcloud"
version = "1.1.0-SNAPSHOT"
repositories {
mavenCentral()
google()
}
tasks.create("downloadDependencies") {
description = "Download all dependencies to the Gradle cache"
doLast {
for (configuration in configurations) {
if (configuration.isCanBeResolved) {
configuration.files
}
}
}
}
normalization {
runtimeClasspath {
metaInf {
ignoreAttribute("Bnd-LastModified")
}
}
}
}
/** Configure building for Java+Kotlin projects. */
subprojects {
val project = this@subprojects
apply(plugin = "java-library")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.plugin.allopen")
apply(plugin = "org.jetbrains.kotlin.plugin.noarg")
if (project.name == "sample") {
apply(plugin = "org.springframework.boot")
} else {
apply(plugin = "java-library")
}
allOpen {
annotations(
"org.springframework.context.annotation.Configuration",
)
}
noArg {
annotation("nxcloud.foundation.core.lang.annotation.NoArgs")
}
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.toString()
}
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs = listOf(
"-Xjvm-default=all",
)
}
}
val testJavaVersion = System.getProperty("test.java.version", "17").toInt()
tasks.withType<Test> {
useJUnitPlatform()
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
jvmArgs = jvmArgs!! + listOf(
"-XX:+HeapDumpOnOutOfMemoryError"
)
val javaToolchains = project.extensions.getByType<JavaToolchainService>()
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(testJavaVersion))
})
maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
testLogging {
exceptionFormat = TestExceptionFormat.FULL
}
systemProperty("junit.jupiter.extensions.autodetection.enabled", "true")
}
tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}
dependencies {
implementation(platform(rootProject.libs.bom.springboot))
implementation("org.slf4j:slf4j-api")
implementation(rootProject.libs.kotlin.logging.jvm)
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
}
}
subprojects {
if (project.name == "sample") {
return@subprojects
}
apply(plugin = "maven-publish")
apply(plugin = "signing")
publishing {
// 发布 release
version = "1.3.3"
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}
publications {
create<MavenPublication>("mavenJava") {
artifactId = "nxcloud-${project.name}"
from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
pom {
name.set("NXCloud SpringMVC AutoMapping")
description.set("A convenient library for auto registering SpringMVC RequestMappings")
url.set("https://github.com/Sunshow/nxcloud-springmvc-automapping")
properties.set(
mapOf(
)
)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("sunshow")
name.set("Sunshow")
email.set("[email protected]")
}
}
scm {
connection.set("https://github.com/Sunshow/nxcloud-springmvc-automapping")
developerConnection.set("https://github.com/Sunshow/nxcloud-springmvc-automapping")
url.set("https://github.com/Sunshow/nxcloud-springmvc-automapping")
}
}
}
}
if (project.hasProperty("publishUsername") && project.hasProperty("publishPassword")
&& project.hasProperty("publishReleasesRepoUrl") && project.hasProperty("publishSnapshotsRepoUrl")
) {
repositories {
maven {
val publishReleasesRepoUrl: String by project
val publishSnapshotsRepoUrl: String by project
url = uri(
if (version.toString().endsWith("SNAPSHOT")) publishSnapshotsRepoUrl else publishReleasesRepoUrl
)
isAllowInsecureProtocol = true
val publishUsername: String by project
val publishPassword: String by project
credentials {
username = publishUsername
password = publishPassword
}
}
}
}
}
signing {
sign(publishing.publications["mavenJava"])
}
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}