@@ -446,6 +446,35 @@ configure(rootProject) {
446446
447447 // docsVersion is also used in documentation.gradle.
448448 ext. docsVersion = project. version. contains(' SNAPSHOT' ) ? ' snapshot' : project. version
449+ ext. docsDir = new File (buildDir, ' ghpages-docs' )
450+
451+ task prepareDocsForUploadToGhPages(dependsOn : [aggregateJavadocs, " :documentation:asciidoctor" ], type : Copy ) {
452+ outputs. dir docsDir
453+
454+ from(project(' :documentation' ). buildDir) {
455+ include ' asciidoc/**'
456+ }
457+ from(" $buildDir /docs" ) {
458+ include ' javadoc/**'
459+ }
460+ into " ${ docsDir} /${ docsVersion} "
461+ filesMatching(' asciidoc/**' ) { fileCopyDetails ->
462+ fileCopyDetails. path = fileCopyDetails. path. replace(' asciidoc/' , ' user-guide/' )
463+ }
464+ filesMatching(' javadoc/**' ) { fileCopyDetails ->
465+ fileCopyDetails. path = fileCopyDetails. path. replace(' javadoc/' , ' api/' )
466+ }
467+ includeEmptyDirs = false
468+ }
469+
470+ task createCurrentDocsFolder(dependsOn : prepareDocsForUploadToGhPages, type : Copy ) {
471+ outputs. dir " ${ docsDir} /current"
472+
473+ from " ${ docsDir} /${ docsVersion} "
474+ into " ${ docsDir} /current"
475+ }
476+
477+ createCurrentDocsFolder. onlyIf { project. hasProperty(' replaceCurrentDocs' ) }
449478
450479 githubPages {
451480 repoUri = ' https://github.com/junit-team/junit5.git'
@@ -456,27 +485,15 @@ configure(rootProject) {
456485 }
457486
458487 pages {
459- from(project(' :documentation' ). buildDir) {
460- include ' asciidoc/**'
461- }
462- from(" $buildDir /docs" ) {
463- include ' javadoc/**'
464- }
465- into " docs/${ docsVersion} "
466- filesMatching(' asciidoc/**' ) { fileCopyDetails ->
467- fileCopyDetails. path = fileCopyDetails. path. replace(' asciidoc/' , ' user-guide/' )
468- }
469- filesMatching(' javadoc/**' ) { fileCopyDetails ->
470- fileCopyDetails. path = fileCopyDetails. path. replace(' javadoc/' , ' api/' )
471- }
472- includeEmptyDirs = false
488+ from docsDir
489+ into " docs"
473490 }
474491
475492 deleteExistingFiles = false
476493 }
477494
478- prepareGhPages. dependsOn(" :documentation:asciidoctor " )
479- prepareGhPages. dependsOn(aggregateJavadocs )
495+ prepareGhPages. dependsOn(prepareDocsForUploadToGhPages )
496+ prepareGhPages. dependsOn(createCurrentDocsFolder )
480497
481498 task wrapper(type : Wrapper ) {
482499 // To build against Gradle 3.0 nightly builds, obtain the latest
0 commit comments