Skip to content

Commit 0d94b3b

Browse files
committed
change link to current version
1 parent 4f8405f commit 0d94b3b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

gradle/plugins/common/src/main/kotlin/junitbuild.javadoc-conventions.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ tasks.javadoc {
3939
noTimestamp(true)
4040
}
4141
}
42+
43+
doLast {
44+
val isCI = System.getenv("CI") != null
45+
val targetString = "https://docs.junit.org/current"
46+
47+
val replacementString = if (isCI) {
48+
val versionNoSnapshot = project.version.toString().replace("-SNAPSHOT", "")
49+
"https://docs.junit.org/$versionNoSnapshot"
50+
} else {
51+
"http://localhost:8080/user-guide"
52+
}
53+
54+
destinationDir?.walkTopDown()
55+
?.filter { it.extension == "html" }
56+
?.forEach { file ->
57+
val content = file.readText()
58+
if (content.contains(targetString)) {
59+
val updatedContent = content.replace(targetString, replacementString)
60+
file.writeText(updatedContent)
61+
}
62+
}
63+
}
4264
}
4365

4466
tasks.named<Jar>("javadocJar").configure {

0 commit comments

Comments
 (0)