@@ -5,16 +5,11 @@ import junitbuild.exec.RunConsoleLauncher
55import junitbuild.extensions.isSnapshot
66import junitbuild.extensions.javaModuleName
77import junitbuild.javadoc.ModuleSpecificJavadocFileOption
8- import org.asciidoctor.gradle.base.AsciidoctorAttributeProvider
9- import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask
108import org.gradle.api.tasks.PathSensitivity.RELATIVE
11- import org.ysb33r.grolifant.api.core.jvm.ExecutionMode.JAVA_EXEC
129
1310plugins {
14- alias(libs.plugins.asciidoctorConvert)
15- alias(libs.plugins.asciidoctorPdf)
16- alias(libs.plugins.gitPublish)
1711 alias(libs.plugins.plantuml)
12+ id(" junitbuild.antora-conventions" )
1813 id(" junitbuild.build-parameters" )
1914 id(" junitbuild.kotlin-library-conventions" )
2015 id(" junitbuild.testing-conventions" )
@@ -84,14 +79,6 @@ dependencies {
8479 standaloneConsoleLauncher(projects.junitPlatformConsoleStandalone)
8580}
8681
87- asciidoctorj {
88- setJrubyVersion(libs.versions.jruby)
89- modules {
90- pdf.version(libs.versions.asciidoctorj.pdf)
91- }
92- requires(file(" src/docs/asciidoc/resources/themes/rouge_junit.rb" ))
93- }
94-
9582val buildRevision: String by rootProject.extra
9683val snapshot = version.isSnapshot()
9784val docsVersion = if (snapshot) " snapshot" else version
@@ -103,30 +90,6 @@ val userGuidePdfFileName = "junit-user-guide-${version}.pdf"
10390val ota4jDocVersion = libs.versions.opentest4j.map { if (it.isSnapshot()) " snapshot" else it }.get()
10491val apiGuardianDocVersion = libs.versions.apiguardian.map { if (it.isSnapshot()) " snapshot" else it }.get()
10592
106- gitPublish {
107- repoUri = " https://github.com/junit-team/docs.junit.org.git"
108-
109- branch = " main"
110- sign = false
111- fetchDepth = 1
112-
113- username = providers.environmentVariable(" GIT_USERNAME" )
114- password = providers.environmentVariable(" GIT_PASSWORD" )
115-
116- contents {
117- from(docsDir)
118- into(" ." )
119- }
120-
121- preserve {
122- include(" **/*" )
123- exclude(" $docsVersion /**" )
124- if (replaceCurrentDocs) {
125- exclude(" current/**" )
126- }
127- }
128- }
129-
13093val generatedAsciiDocPath = layout.buildDirectory.dir(" generated/asciidoc" )
13194val consoleLauncherOptionsFile = generatedAsciiDocPath.map { it.file(" console-launcher-options.txt" ) }
13295val consoleLauncherDiscoverOptionsFile = generatedAsciiDocPath.map { it.file(" console-launcher-discover-options.txt" ) }
@@ -270,8 +233,8 @@ tasks {
270233
271234 val plantUmlOutputDirectory = plantUml.flatMap { it.outputDirectory }
272235
273- withType< AbstractAsciidoctorTask >().configureEach {
274- inputs.files (
236+ val generateAsciidocInputs by registering {
237+ dependsOn (
275238 generateConsoleLauncherOptions,
276239 generateConsoleLauncherDiscoverOptions,
277240 generateConsoleLauncherExecuteOptions,
@@ -280,100 +243,6 @@ tasks {
280243 generateStandaloneConsoleLauncherShadowedArtifactsFile,
281244 plantUmlOutputDirectory
282245 )
283-
284- resources {
285- from(sourceDir) {
286- include(" **/images/**/*.png" )
287- include(" **/images/**/*.svg" )
288- }
289- from(plantUmlOutputDirectory) {
290- into(" user-guide/images" )
291- }
292- }
293-
294- // Temporary workaround for https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/599
295- inputs.dir(sourceDir).withPropertyName(" sourceDir" ).withPathSensitivity(RELATIVE )
296-
297- attributeProviders + = AsciidoctorAttributeProvider {
298- mapOf (
299- " version" to version,
300- " junit4-version" to libs.versions.junit4.get(),
301- " apiguardian-version" to libs.versions.apiguardian.get(),
302- " ota4j-version" to libs.versions.opentest4j.get(),
303- " surefire-version" to libs.versions.surefire.get(),
304- " release-branch" to releaseBranch,
305- " docs-version" to docsVersion,
306- " revnumber" to version,
307- " consoleLauncherOptionsFile" to consoleLauncherOptionsFile.get(),
308- " consoleLauncherDiscoverOptionsFile" to consoleLauncherDiscoverOptionsFile.get(),
309- " consoleLauncherExecuteOptionsFile" to consoleLauncherExecuteOptionsFile.get(),
310- " consoleLauncherEnginesOptionsFile" to consoleLauncherEnginesOptionsFile.get(),
311- " experimentalApisTableFile" to experimentalApisTableFile.get(),
312- " deprecatedApisTableFile" to deprecatedApisTableFile.get(),
313- " standaloneConsoleLauncherShadowedArtifactsFile" to standaloneConsoleLauncherShadowedArtifactsFile.get(),
314- " outdir" to outputDir.absolutePath,
315- " source-highlighter" to " rouge" ,
316- " rouge-style" to " junit" ,
317- " tabsize" to " 4" ,
318- " toc" to " left" ,
319- " icons" to " font" ,
320- " sectanchors" to true ,
321- " idprefix" to " " ,
322- " idseparator" to " -" ,
323- " jdk-javadoc-base-url" to jdkJavadocBaseUrl
324- )
325- }
326-
327- sourceSets[" test" ].apply {
328- attributes(mapOf (
329- " testDir" to java.srcDirs.first(),
330- " testResourcesDir" to resources.srcDirs.first()
331- ))
332- inputs.dir(java.srcDirs.first())
333- inputs.dir(resources.srcDirs.first())
334- attributes(mapOf (" kotlinTestDir" to kotlin.srcDirs.first()))
335- inputs.dir(kotlin.srcDirs.first())
336- }
337-
338- jvm {
339- // To avoid warning, see https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/597
340- jvmArgs(
341- " --add-opens" , " java.base/sun.nio.ch=ALL-UNNAMED" ,
342- " --add-opens" , " java.base/java.io=ALL-UNNAMED"
343- )
344- }
345-
346- notCompatibleWithConfigurationCache(" https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/564" )
347- }
348-
349- asciidoctor {
350- sources {
351- include(" **/index.adoc" )
352- }
353- resources {
354- from(sourceDir) {
355- include(" tocbot-*/**" )
356- }
357- }
358- attributes(mapOf (
359- " linkToPdf" to uploadPdfs,
360- " userGuidePdfFileName" to userGuidePdfFileName,
361- " releaseNotesUrl" to " ../release-notes/index.html#release-notes"
362- ))
363- }
364-
365- asciidoctorPdf {
366- // Avoid classpath conflicts with other Gradle plugins (e.g. JReleaser)
367- // Avoid propagating apparent memory leaks in Asciidoctor/JRuby to Gradle daemon.
368- setExecutionMode(JAVA_EXEC )
369- jvm {
370- maxHeapSize = " 512M"
371- }
372- sources {
373- include(" user-guide/index.adoc" )
374- }
375- copyAllResources()
376- attributes(mapOf (" releaseNotesUrl" to " https://docs.junit.org/$docsVersion /release-notes/" ))
377246 }
378247
379248 val downloadJavadocElementLists by registering {
@@ -496,58 +365,28 @@ tasks {
496365 into(layout.buildDirectory.dir(" docs/fixedJavadoc" ))
497366 }
498367
499- val prepareDocsForUploadToGhPages by registering(Copy ::class ) {
500- dependsOn(fixJavadoc, asciidoctor, asciidoctorPdf)
501- outputs.dir(docsDir)
502-
503- from(asciidoctor.map { it.outputDir }) {
504- include(" user-guide/**" )
505- include(" release-notes/**" )
506- include(" tocbot-*/**" )
507- }
508- if (uploadPdfs) {
509- from(asciidoctorPdf.map { it.outputDir }) {
510- include(" **/*.pdf" )
511- rename { userGuidePdfFileName }
512- }
513- }
514- from(fixJavadoc.map { it.destinationDir }) {
515- into(" api" )
516- }
517- into(docsDir.map { it.dir(docsVersion.toString()) })
518- includeEmptyDirs = false
519- }
520-
521- val createCurrentDocsFolder by registering(Copy ::class ) {
522- dependsOn(prepareDocsForUploadToGhPages)
523- onlyIf { replaceCurrentDocs }
524-
525- from(docsDir.map { it.dir(docsVersion.toString()) })
526- into(docsDir.map { it.dir(" current" ) })
527- }
528-
529- val configureGitAuthor by registering {
530- dependsOn(gitPublishReset)
531- doFirst {
532- File (gitPublish.repoDir.get().asFile, " .git/config" ).appendText("""
533- [user]
534- name = JUnit Team
535- email = team@junit.org
536- """ .trimIndent())
537- }
538- }
539-
540- gitPublishCopy {
541- dependsOn(prepareDocsForUploadToGhPages, createCurrentDocsFolder)
542- }
543-
544- gitPublishCommit {
545- dependsOn(configureGitAuthor)
546- }
547-
548368 val prepareGitHubAttestation by registering(Sync ::class ) {
549369 from(attestationClasspath)
550370 into(layout.buildDirectory.dir(" attestation" ))
551371 rename(" (.*)-SNAPSHOT.jar" , " $1-SNAPSHOT+${buildRevision.substring(0 , 7 )} .jar" )
552372 }
373+
374+ generateAntoraYml {
375+ asciidocAttributes.putAll(provider {
376+ mapOf (
377+ " version" to project.version,
378+ " junit4-version" to libs.versions.junit4.get(),
379+ " apiguardian-version" to libs.versions.apiguardian.get(),
380+ " ota4j-version" to libs.versions.opentest4j.get(),
381+ " surefire-version" to libs.versions.surefire.get(),
382+ " release-branch" to releaseBranch,
383+ " docs-version" to docsVersion,
384+ " jdk-javadoc-base-url" to jdkJavadocBaseUrl
385+ )
386+ })
387+ }
388+
389+ generateAntoraResources {
390+ dependsOn(generateAsciidocInputs, fixJavadoc)
391+ }
553392}
0 commit comments