Skip to content

Commit 2789671

Browse files
committed
1 parent 7124f4b commit 2789671

File tree

2 files changed

+70
-65
lines changed

2 files changed

+70
-65
lines changed

build.gradle.kts

+69-64
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import org.jetbrains.dokka.gradle.DokkaTask
2-
import org.jetbrains.dokka.gradle.DokkaTaskPartial
3-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
41
import java.net.URL
52
import java.time.OffsetDateTime
63
import java.time.format.DateTimeFormatter
74

5+
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
6+
import org.jetbrains.dokka.gradle.DokkaTask
7+
import org.jetbrains.dokka.gradle.DokkaTaskPartial
8+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
9+
810
plugins {
911
with(Plugins) {
1012
id("org.ajoberstar.grgit") version GRGIT
@@ -70,47 +72,27 @@ subprojects {
7072
}
7173
}
7274

75+
val actualJavaVersion = if (JAVA_VERSION <= 10) "1.$JAVA_VERSION" else "$JAVA_VERSION"
76+
7377
configure<JavaPluginExtension> {
74-
sourceCompatibility = JavaVersion.valueOf("VERSION_$JAVA_VERSION")
78+
sourceCompatibility = JavaVersion.valueOf(
79+
"VERSION_${actualJavaVersion.replace(".", "_")}"
80+
)
7581
targetCompatibility = sourceCompatibility
7682
}
7783

7884
tasks {
79-
withType<Test> {
80-
useJUnitPlatform()
81-
}
82-
8385
withType<JavaCompile> {
84-
options.release.set(JAVA_VERSION)
86+
sourceCompatibility = actualJavaVersion
87+
targetCompatibility = actualJavaVersion
8588
}
8689

8790
withType<KotlinCompile> {
88-
kotlinOptions.jvmTarget = "$JAVA_VERSION"
91+
kotlinOptions.jvmTarget = actualJavaVersion
8992
}
9093

91-
withType<DokkaTaskPartial>().configureEach {
92-
dokkaSourceSets.configureEach {
93-
displayName.set("${Coordinates.name}/${project.name} on ${Coordinates.gitHost}")
94-
95-
skipDeprecated.set(false)
96-
includeNonPublic.set(false)
97-
skipEmptyPackages.set(true)
98-
reportUndocumented.set(true)
99-
suppressObviousFunctions.set(true)
100-
101-
// Link the source to the documentation
102-
sourceLink {
103-
localDirectory.set(file("src"))
104-
remoteUrl.set(URL("${Coordinates.gitUrl}/tree/${Coordinates.mainGitBranch}/${project.name}/src"))
105-
}
106-
107-
/**
108-
* @see config.Dokka.externalDocumentations
109-
*/
110-
config.Dokka.externalDocumentations.forEach {
111-
externalDocumentationLink { url.set(URL(it)) }
112-
}
113-
}
94+
withType<Test> {
95+
useJUnitPlatform()
11496
}
11597

11698
withType<Jar> {
@@ -126,26 +108,27 @@ subprojects {
126108

127109
with(Coordinates) {
128110
manifest.attributes(
129-
"Name" to group.replace(".", "/") + "/",
111+
"Name" to group.replace(".", "/") + "/" + project.name + "/",
130112

131113
"Created-By" to "$javaVersion ($javaVendor $javaVmVersion)",
132114
"Build-Date" to buildDate,
133115
"Build-Time" to buildTime,
134116
"Build-Revision" to buildRevision,
135117

136-
"Specification-Title" to "$name:${project.name}",
118+
"Specification-Title" to project.name,
137119
"Specification-Version" to prettyProjectVersion,
138120
"Specification-Vendor" to vendor,
139121

140-
"Implementation-Title" to project.name,
122+
"Implementation-Title" to "$name-${project.name}",
141123
"Implementation-Version" to buildRevision,
142124
"Implementation-Vendor" to vendor,
143125

144-
"Bundle-Name" to name,
145-
"Bundle-Description" to description,
126+
"Bundle-Name" to "$name-${project.name}",
127+
// the README.md file always contains the module description on its 3rd line.
128+
"Bundle-Description" to projectDir.resolve("README.md").readLines()[2],
146129
"Bundle-DocURL" to gitUrl,
147130
"Bundle-Vendor" to vendor,
148-
"Bundle-SymbolicName" to "$group.$name",
131+
"Bundle-SymbolicName" to "$group.${project.name}",
149132
)
150133
}
151134

@@ -162,6 +145,43 @@ subprojects {
162145
from("LICENSE")
163146
}
164147

148+
withType<DokkaTask>().configureEach {
149+
moduleName.set("${Coordinates.name}-${project.name}")
150+
}
151+
152+
withType<DokkaTaskPartial>().configureEach {
153+
moduleName.set(project.name)
154+
155+
dokkaSourceSets.configureEach {
156+
includes.from(projectDir.resolve("README.md"))
157+
158+
displayName.set("${Coordinates.name}/${moduleName.get()} on ${Coordinates.gitHost}")
159+
160+
skipDeprecated.set(false)
161+
includeNonPublic.set(false)
162+
skipEmptyPackages.set(true)
163+
reportUndocumented.set(true)
164+
suppressObviousFunctions.set(true)
165+
166+
// Link the source to the documentation
167+
sourceLink {
168+
localDirectory.set(file("src"))
169+
remoteUrl.set(
170+
URL(
171+
"${Coordinates.gitUrl}/tree/${Coordinates.mainGitBranch}/${project.name}/src"
172+
)
173+
)
174+
}
175+
176+
/**
177+
* @see config.Dokka.externalDocumentations
178+
*/
179+
config.Dokka.externalDocumentations.forEach {
180+
externalDocumentationLink { url.set(URL(it)) }
181+
}
182+
}
183+
}
184+
165185
// The Javadoc artifact, containing the Dokka output and the LICENSE file.
166186
create("javadocJar", Jar::class) {
167187
group = "build"
@@ -227,30 +247,16 @@ subprojects {
227247
}
228248
}
229249

230-
afterEvaluate {
231-
tasks.dokkaHtmlMultiModule {
232-
val moduleFile = File(
233-
projectDir,
234-
"MODULE.temp.${java.util.UUID.randomUUID()}.md"
235-
)
236-
237-
// In order to have a description on the rendered docs, we have to have
238-
// a file with the # Module thingy in it. That's what we're
239-
// automagically creating and deleting here.
240-
run {
241-
doFirst {
242-
moduleFile.deleteOnExit()
243-
moduleFile.writeText(
244-
"# ${Coordinates.name}\n${Coordinates.description}"
245-
)
246-
}
247-
248-
doLast { moduleFile.delete() }
249-
}
250-
251-
moduleName.set(Coordinates.name)
252-
includes.from(moduleFile.path)
250+
tasks.withType<DokkaMultiModuleTask>().configureEach {
251+
val moduleFile = File(
252+
temporaryDir,
253+
"MODULE.${java.util.UUID.randomUUID()}.md"
254+
).apply {
255+
writeText("# ${Coordinates.name} by ${Coordinates.vendor}\n${Coordinates.description}\n<a href=\"${Coordinates.gitUrl}\">Source</a>")
253256
}
257+
258+
moduleName.set(Coordinates.name)
259+
includes.from(moduleFile)
254260
}
255261

256262
// Configure publishing to Maven Central
@@ -262,8 +268,7 @@ nexusPublishing.repositories.sonatype {
262268
)
263269
)
264270

265-
// Skip this step if environment variables NEXUS_USERNAME or NEXUS_PASSWORD
266-
// aren't set.
271+
// Skip this step if environment variables NEXUS_USERNAME or NEXUS_PASSWORD aren't set.
267272
username.set(properties["NEXUS_USERNAME"] as? String ?: return@sonatype)
268273
password.set(properties["NEXUS_PASSWORD"] as? String ?: return@sonatype)
269274
}

buildSrc/src/main/kotlin/coords.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const val JAVA_VERSION: Int = 17
22

33
object Coordinates {
4-
const val name = "core"
4+
const val name = "Core"
55
const val description = "Mizu Client's core monolithic repository."
66
const val vendor = "Mizu Software"
77

0 commit comments

Comments
 (0)