diff --git a/src/it/projects/reproducible/invoker.properties b/src/it/projects/reproducible/invoker.properties
index 80190f7e9..7a0e7df7a 100644
--- a/src/it/projects/reproducible/invoker.properties
+++ b/src/it/projects/reproducible/invoker.properties
@@ -14,4 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+# javadoc has some annoying bugs that make the output unreproducible:
+# See: https://issues.apache.org/jira/browse/MJAVADOC-681
+# https://bugs.openjdk.org/browse/JDK-8268771
+# https://bugs.openjdk.org/browse/JDK-8237909
+
+# To create "reproducible" javadoc you need to use Java 8 or Java 15+
+invoker.java.version = 1.8, 15+
invoker.goals = compile javadoc:jar
diff --git a/src/it/projects/reproducible/pom.xml b/src/it/projects/reproducible/pom.xml
index 78cca7e8e..527eb8eaa 100644
--- a/src/it/projects/reproducible/pom.xml
+++ b/src/it/projects/reproducible/pom.xml
@@ -26,6 +26,8 @@
bar
0.1.0-SNAPSHOT
+ 2010
+
UTF-8
@maven.compiler.source@
@@ -39,9 +41,6 @@
org.apache.maven.plugins
maven-javadoc-plugin
@project.version@
-
- true
-
diff --git a/src/it/projects/reproducible/verify.groovy b/src/it/projects/reproducible/verify.groovy
index 83d30ed8f..3033be711 100644
--- a/src/it/projects/reproducible/verify.groovy
+++ b/src/it/projects/reproducible/verify.groovy
@@ -29,7 +29,7 @@ assert apidocs.isDirectory()
def options = new File( apidocs, 'options' )
assert options.isFile()
-assert options.text.contains( "'Copyright © 2020. All rights reserved.'" )
+assert options.text.contains( "'Copyright © 2010–2020. All rights reserved.'" )
def artifact = new File( target, 'bar-0.1.0-SNAPSHOT-javadoc.jar' )
assert artifact.isFile()
@@ -39,7 +39,8 @@ apidocs.eachFileRecurse
{
if ( it.name.endsWith( '.html' ) )
{
- assert it.text =~ //
+ def line = it.text.readLines().find { it.startsWith( "/
}
}
@@ -53,13 +54,8 @@ long normalizeUTC( String timestamp )
}
JarFile jar = new JarFile( artifact )
+assert jar.stream().count() > 0
// All entries should have the same timestamp
FileTime expectedTimestamp = FileTime.fromMillis( normalizeUTC( "2020-02-29T23:59:58Z" ) )
-def testTimestamp =
-{
- JarEntry entry -> assert expectedTimestamp.equals( entry.getLastModifiedTime() )
-}
-
-jar.stream().forEach( testTimestamp )
-jar.close()
+jar.stream().forEach { assert expectedTimestamp.equals( it.getLastModifiedTime() ) }
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index 71c78919f..543c4000c 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -1286,14 +1286,16 @@ public abstract class AbstractJavadocMojo
/**
* Suppresses the timestamp, which is hidden in an HTML comment in the generated HTML near the top of each page.
- *
+ *
+ * Note: If the project has the property project.build.outputTimestamp
, the value
+ * will be overwritten to true. This way it is possible to generate reproducible javadoc jars.
+ *
* See
* notimestamp.
- *
+ *
* Since
*
* Java 5.0.
- *
*
* @since 2.1
*/
@@ -5654,7 +5656,7 @@ private void addStandardDocletOptions( File javadocOutputDirectory,
addArgIf( arguments, nosince, "-nosince" );
- if ( MavenArchiver.parseBuildOutputTimestamp( outputTimestamp ).isPresent() )
+ if ( !notimestamp && MavenArchiver.parseBuildOutputTimestamp( outputTimestamp ).isPresent() )
{
// Override the notimestamp option if a Reproducible Build is requested.
notimestamp = true;