Skip to content

Commit

Permalink
Skip Java 9-14 in reproducible test
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Solórzano <jorsol@gmail.com>
  • Loading branch information
jorsol authored and slawekjaranowski committed Jul 8, 2022
1 parent 26d84b2 commit c19dba2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
8 changes: 8 additions & 0 deletions src/it/projects/reproducible/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions src/it/projects/reproducible/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<artifactId>bar</artifactId>
<version>0.1.0-SNAPSHOT</version>

<inceptionYear>2010</inceptionYear>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
Expand All @@ -39,9 +41,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<notimestamp>true</notimestamp>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
14 changes: 5 additions & 9 deletions src/it/projects/reproducible/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ assert apidocs.isDirectory()

def options = new File( apidocs, 'options' )
assert options.isFile()
assert options.text.contains( "'Copyright &#169; 2020. All rights reserved.'" )
assert options.text.contains( "'Copyright &#169; 2010&#x2013;2020. All rights reserved.'" )

def artifact = new File( target, 'bar-0.1.0-SNAPSHOT-javadoc.jar' )
assert artifact.isFile()
Expand All @@ -39,7 +39,8 @@ apidocs.eachFileRecurse
{
if ( it.name.endsWith( '.html' ) )
{
assert it.text =~ /<!-- Generated by javadoc (\(\d+\) )?-->/
def line = it.text.readLines().find { it.startsWith( "<!-- Generated by javadoc" ) }
assert line ==~ /<!-- Generated by javadoc (\(\d+\) )?-->/
}
}

Expand All @@ -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() ) }
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <br/>
* <br><br>
* <strong>Note:</strong> If the project has the property <code>project.build.outputTimestamp</code>, the value
* will be overwritten to true. This way it is possible to generate reproducible javadoc jars.
* <br><br>
* See
* <a href="https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#notimestamp">notimestamp</a>.
* <br/>
* <br>
* Since
* <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-1.5.0.html#commandlineoptions">
* Java 5.0</a>.
* <br/>
*
* @since 2.1
*/
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c19dba2

Please # to comment.