From ed9cb125198614c8b74877d85ceca6c8341fb0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Sol=C3=B3rzano?= Date: Fri, 8 Jul 2022 13:58:47 +0200 Subject: [PATCH] Skip Java 9-14 in reproducible test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jorge Solórzano --- src/it/projects/reproducible/invoker.properties | 8 ++++++++ src/it/projects/reproducible/pom.xml | 5 ++--- src/it/projects/reproducible/verify.groovy | 14 +++++--------- .../maven/plugins/javadoc/AbstractJavadocMojo.java | 10 ++++++---- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/it/projects/reproducible/invoker.properties b/src/it/projects/reproducible/invoker.properties index 80190f7e..7a0e7df7 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 78cca7e8..527eb8ea 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 83d30ed8..3033be71 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 71c78919..543c4000 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;