asciidoctor-gradle-plugin icon indicating copy to clipboard operation
asciidoctor-gradle-plugin copied to clipboard

asciidotor added twice to distribution

Open kec2 opened this issue 5 years ago • 6 comments

When I create a distribution of my application using Gradle Application, which includes the output of the asciidoctor task, it is added twice.

plugins {
    id 'org.asciidoctor.jvm.convert' version '2.2.0'
}

apply plugin: 'application'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.12.1'
    implementation 'org.apache.commons:commons-text:1.8'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

jar {
    from sourceSets.main.allJava
}

mainClassName = "dk.kec.MyApp"

distributions {
    main.contents {
        from(asciidoctor) {
            into 'docs'
        }
    }
}

asciidoctor {
    sourceDir file('docs')
    sources {
        include 'readme.adoc'
    }
    outputDir file("$buildDir/asciidoc")
}

kec2 avatar Nov 28 '19 13:11 kec2

Im on Window 10. Gradle 6.0.1 Java 8.0.231

kec2 avatar Nov 28 '19 13:11 kec2

Not sure what is happening there as it soudns like it should just work. I'll take a look.

ysb33r avatar Nov 29 '19 19:11 ysb33r

The problem can be replicated on MacOS too. Using the build file above on a sample project yields

$ unzip -l build/distributions/foo.zip 
Archive:  build/distributions/foo.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  11-29-2019 21:31   foo/
        0  11-29-2019 21:31   foo/lib/
      855  11-29-2019 21:31   foo/lib/foo.jar
    23518  11-29-2019 21:29   foo/lib/log4j-slf4j-impl-2.12.1.jar
   207030  11-29-2019 21:29   foo/lib/commons-text-1.8.jar
    41203  11-29-2019 21:29   foo/lib/slf4j-api-1.7.25.jar
  1674433  11-29-2019 21:29   foo/lib/log4j-core-2.12.1.jar
   276771  11-29-2019 21:29   foo/lib/log4j-api-2.12.1.jar
   503880  10-14-2019 10:22   foo/lib/commons-lang3-3.9.jar
        0  11-29-2019 21:31   foo/bin/
     3039  11-29-2019 21:31   foo/bin/foo.bat
     5857  11-29-2019 21:31   foo/bin/foo
        0  11-29-2019 21:31   foo/docs/
    31042  11-29-2019 21:31   foo/docs/readme.html
    31042  11-29-2019 21:31   foo/docs/readme.html
---------                     -------
  2798670                     15 files

$ tree build
build
├── asciidoc
│   └── readme.html
├── classes
│   └── java
│       └── main
│           └── Foo.class
├── distributions
│   └── foo.zip
├── generated
│   └── sources
│       └── annotationProcessor
│           └── java
│               └── main
├── libs
│   └── foo.jar
├── scripts
│   ├── foo
│   └── foo.bat
└── tmp
    ├── asciidoctor.javaexec-data
    └── jar
        └── MANIFEST.MF

Note that readme.html exists only once in the build directory but it's added twice to the zip file.

aalmiray avatar Nov 29 '19 20:11 aalmiray

Tried different versions of Gradle from 6.0.1 all the way back to 4.0 (3.5 doesn't seem to work with asciidoctor-gradle 2.2.0) and all of them generate a duplicate entry in the zip file. I thought that the application plugin was at fault as there were updates to it in the middle of Gradle 4.x and a full revamp in 5.x but no, there's something odd going on here.

aalmiray avatar Nov 29 '19 20:11 aalmiray

It seams that asciidoctor declares twice the output path.

With Gradle 6.0 this warning was added:

> Task :distTar
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "catalog-export-1.0/docs/catalog-export.html". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths.

jxerome avatar Dec 16 '19 09:12 jxerome

The problem seems to be fixed since Gradle 6.6. I can reproduce the issue only with Gradle 6.5.1 or below.

For 6.5.1 or below, a workaround is to write from(asciidoctor.outputdir) and to make the dependency, which is implicit in from(asciidoctor), explicit.

hpoettker avatar May 25 '21 14:05 hpoettker