/
build.gradle.kts
183 lines (168 loc) · 6.56 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
/*
* Copyright (c) 2023-2024. lWoHvYe(Hongyan Wang)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 这种是legacy的configuration,但针对未publish到maven central的,还是要这种方式才行(dependencies部分)
buildscript {
repositories {
gradlePluginPortal()
// Should in hierarchy
maven {
name = "extra-repo"
url = uri("$rootProject.projectDir/ex-lib")
}
}
}
plugins {
id("com.lwohvye.java-conventions")
//主要是定义了这个,定义了SpringBoot的Version相关,并提供了application, bootJar, bootBuildImage这些Task
alias(libs.plugins.spring.boot) apply false
// This plugin simplifies the use of Lombok in Gradle
id("io.freefair.lombok") version "8.6"
id("me.champeau.mrjar") version "0.1.1"
id("org.gradlex.extra-java-module-info") version "1.8"
// 在parent root执行Task,会同步执行sub project的Task,比如执行了bootJar,那会执行subPro的bootJar(若其中没有该Task会ignore)
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}
extra["sharedManifest"] = java.manifest {
attributes(
"Developer" to "lWoHvYe",
"Created-By" to "Gradle",
"Built-By" to System.getProperty("user.name"),
"Build-Jdk-Spec" to System.getProperty("java.version")
)
}
subprojects {
apply(plugin = "com.lwohvye.java-conventions")
apply(plugin = "org.gradlex.extra-java-module-info")
apply(plugin = "io.freefair.lombok")
// Setting a custom Lombok version when use plugin io.freefair.lombok
lombok {
version = "1.18.32"
}
java {
registerFeature("coreComp") {
usingSourceSet(sourceSets["main"])
}
}
dependencies {
// implementation(libs.asm)
"coreCompCompileOnly"("org.mapstruct", "mapstruct-processor", "1.5.5.Final")
annotationProcessor("org.mapstruct", "mapstruct-processor", "1.5.5.Final")
annotationProcessor("org.mapstruct.extensions.spring", "mapstruct-spring-extensions", "1.1.0")
}
tasks.withType<Javadoc>().configureEach {
isFailOnError = false
(options as StandardJavadocDocletOptions).apply {
addStringOption("Xdoclint:none", "-quiet")
addStringOption("encoding", "UTF-8")
addStringOption("charSet", "UTF-8")
// Add support for custom tag
addStringOption("tag", "date:a:Init Date:")
addStringOption("tag", "author:a:Major Contributor:")
}
}
extraJavaModuleInfo {
// deriveAutomaticModuleNamesFromFileNames = true // failed due to split package issue
// legacy configure start
failOnMissingModuleInfo.set(false)
automaticModule("io.github.mouzt:bizlog-sdk", "bizlog.sdk")
automaticModule("com.github.whvcse:easy-captcha", "easy.captcha")
automaticModule("io.jsonwebtoken:jjwt-api", "jjwt.api")
automaticModule("org.quartz-scheduler:quartz", "quartz")
automaticModule("org.springframework.retry:spring-retry", "spring.retry")
// end
}
}
allprojects {
tasks.withType<Javadoc> {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)) {
(options as StandardJavadocDocletOptions).apply {
addBooleanOption("-enable-preview", true)
addStringOption("-release", "21")
}
}
}
}
tasks.withType<Checkstyle>().configureEach {
reports {
xml.required.set(false)
}
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "unicorn"
from(components["java"])
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
pom {
name.set("Valentine Unicorn")
packaging = "pom"
// optionally artifactId can be defined here
description.set("A Spring Boot Project With Jpa JWT Security and so on")
url.set("https://github.com/lWoHvYe/unicorn.git")
properties = mapOf(
"myProp" to "chaste unicorn",
"spring-boot.version" to "${property("springBootVersion")}",
"project.core.version" to version
)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("lWoHvYe")
name.set("王红岩(lWoHvYe)")
email.set("lWoHvYe@outlook.com")
url.set("https://www.lwohvye.com")
}
}
scm {
connection.set("scm:git:git://github.com/lWoHvYe/unicorn.git")
developerConnection.set("scm:git:ssh://github.com/lWoHvYe/unicorn.git")
url.set("https://github.com/lWoHvYe/unicorn/tree/main")
tag.set("unicorn-v$version")
}
}
}
}
}
// this is the equivalent of the `nexusPublishing` block
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.set(findProperty("ossrhUsername") as String? ?: System.getenv("OSSRH_USERNAME"))
password.set(findProperty("ossrhPassword") as String? ?: System.getenv("OSSRH_PASSWORD"))
}
}
}