Skip to content

Commit 6bd9b7e

Browse files
committed
Reorganize build conventions
1 parent 3b8641c commit 6bd9b7e

File tree

6 files changed

+88
-78
lines changed

6 files changed

+88
-78
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
application
3-
id("tai-e.conventions")
3+
id("java.conventions")
4+
id("checkstyle.conventions")
45
id("maven-publish.conventions")
56
}
67

buildSrc/src/main/kotlin/CheckstyleUtils.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ fun summarizeStyleViolations(checkstyle: Checkstyle): String? {
3838
var id = 1
3939
violationGroup.forEach {
4040
it.forEach {
41-
result.append("\n#${id++}: ${it.msg}\n rule: ${it.source}\n Please click to fix: ${it.path}")
41+
result.append("\n#${id++}: ${it.msg} (corresponding rule is ${it.source})")
42+
// use file protocol to help quick locating
43+
val path = it.path.replace("\\", "/")
44+
val pathWithFileProtocol = if (path.startsWith("/")) {
45+
"file://" + path
46+
} else {
47+
"file:///" + path
48+
}
49+
result.append("\n Please click to fix: ${pathWithFileProtocol}")
4250
}
4351
}
4452
return result.toString().removeHtmlTag()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
plugins {
2+
checkstyle
3+
}
4+
5+
// checks the code style after compilation
6+
tasks.findByName("classes")?.finalizedBy("checkstyleMain")
7+
tasks.findByName("testClasses")?.finalizedBy("checkstyleTest")
8+
9+
// custom the report format
10+
checkstyle {
11+
isShowViolations = false
12+
}
13+
tasks.withType<Checkstyle> {
14+
// only xml need
15+
reports {
16+
xml.required.set(true)
17+
html.required.set(false)
18+
}
19+
// report the error style to help developers fix it
20+
doLast { summarizeStyleViolations(this as Checkstyle)?.let(logger::warn) }
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugins {
2+
java
3+
jacoco
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
}
9+
10+
java {
11+
toolchain {
12+
languageVersion.set(javaVersion)
13+
}
14+
}
15+
16+
tasks.withType<JavaCompile> {
17+
options.encoding = "UTF-8"
18+
}
19+
20+
// jacoco
21+
tasks.jacocoTestReport {
22+
reports {
23+
xml.required.set(true)
24+
}
25+
}

buildSrc/src/main/kotlin/maven-publish.conventions.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,37 @@ java {
1414
withSourcesJar()
1515
}
1616

17+
tasks.withType<Javadoc> {
18+
val javadocConfigDir = rootProject.rootDir.resolve(
19+
"config/javadoc/")
20+
fun String.escapeLineBreaking() = this.replace("\r", "")
21+
.replace("\n", "")
22+
options {
23+
this as StandardJavadocDocletOptions
24+
// style
25+
title = "Tai-e $projectVersion API"
26+
overview = javadocConfigDir.resolve("overview.html").path
27+
addStringOption("-add-stylesheet",
28+
javadocConfigDir.resolve("javadoc.css").path)
29+
header = javadocConfigDir.resolve("header.html").readText().escapeLineBreaking()
30+
bottom = javadocConfigDir.resolve("footer.html").readText().escapeLineBreaking()
31+
// fix language and encoding
32+
encoding = "UTF-8"
33+
docEncoding = "UTF-8"
34+
locale = "en"
35+
jFlags("-Duser.language=en")
36+
// suppress the warning(s)
37+
addBooleanOption("Xdoclint:all,-missing", true)
38+
// others
39+
splitIndex(true)
40+
use(true)
41+
noTimestamp(true)
42+
memberLevel = JavadocMemberLevel.PROTECTED
43+
addBooleanOption("html5", true)
44+
links("https://docs.oracle.com/en/java/javase/17/docs/api")
45+
}
46+
}
47+
1748
val signingKeyId: String? by project // env.ORG_GRADLE_PROJECT_signingKeyId
1849
val signingKey: String? by project // env.ORG_GRADLE_PROJECT_signingKey
1950
val signingPassword: String? by project // env.ORG_GRADLE_PROJECT_signingPassword

buildSrc/src/main/kotlin/tai-e.conventions.gradle.kts

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)