Skip to content

Commit c19dba2

Browse files
jorsolslawekjaranowski
authored andcommitted
Skip Java 9-14 in reproducible test
Signed-off-by: Jorge Solórzano <[email protected]>
1 parent 26d84b2 commit c19dba2

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/it/projects/reproducible/invoker.properties

+8
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
18+
# javadoc has some annoying bugs that make the output unreproducible:
19+
# See: https://issues.apache.org/jira/browse/MJAVADOC-681
20+
# https://bugs.openjdk.org/browse/JDK-8268771
21+
# https://bugs.openjdk.org/browse/JDK-8237909
22+
23+
# To create "reproducible" javadoc you need to use Java 8 or Java 15+
24+
invoker.java.version = 1.8, 15+
1725
invoker.goals = compile javadoc:jar

src/it/projects/reproducible/pom.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<artifactId>bar</artifactId>
2727
<version>0.1.0-SNAPSHOT</version>
2828

29+
<inceptionYear>2010</inceptionYear>
30+
2931
<properties>
3032
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3133
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
@@ -39,9 +41,6 @@
3941
<groupId>org.apache.maven.plugins</groupId>
4042
<artifactId>maven-javadoc-plugin</artifactId>
4143
<version>@project.version@</version>
42-
<configuration>
43-
<notimestamp>true</notimestamp>
44-
</configuration>
4544
</plugin>
4645
</plugins>
4746
</build>

src/it/projects/reproducible/verify.groovy

+5-9
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ assert apidocs.isDirectory()
2929

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

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

@@ -53,13 +54,8 @@ long normalizeUTC( String timestamp )
5354
}
5455

5556
JarFile jar = new JarFile( artifact )
57+
assert jar.stream().count() > 0
5658

5759
// All entries should have the same timestamp
5860
FileTime expectedTimestamp = FileTime.fromMillis( normalizeUTC( "2020-02-29T23:59:58Z" ) )
59-
def testTimestamp =
60-
{
61-
JarEntry entry -> assert expectedTimestamp.equals( entry.getLastModifiedTime() )
62-
}
63-
64-
jar.stream().forEach( testTimestamp )
65-
jar.close()
61+
jar.stream().forEach { assert expectedTimestamp.equals( it.getLastModifiedTime() ) }

src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1286,14 +1286,16 @@ public abstract class AbstractJavadocMojo
12861286

12871287
/**
12881288
* Suppresses the timestamp, which is hidden in an HTML comment in the generated HTML near the top of each page.
1289-
* <br/>
1289+
* <br><br>
1290+
* <strong>Note:</strong> If the project has the property <code>project.build.outputTimestamp</code>, the value
1291+
* will be overwritten to true. This way it is possible to generate reproducible javadoc jars.
1292+
* <br><br>
12901293
* See
12911294
* <a href="https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#notimestamp">notimestamp</a>.
1292-
* <br/>
1295+
* <br>
12931296
* Since
12941297
* <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-1.5.0.html#commandlineoptions">
12951298
* Java 5.0</a>.
1296-
* <br/>
12971299
*
12981300
* @since 2.1
12991301
*/
@@ -5654,7 +5656,7 @@ private void addStandardDocletOptions( File javadocOutputDirectory,
56545656

56555657
addArgIf( arguments, nosince, "-nosince" );
56565658

5657-
if ( MavenArchiver.parseBuildOutputTimestamp( outputTimestamp ).isPresent() )
5659+
if ( !notimestamp && MavenArchiver.parseBuildOutputTimestamp( outputTimestamp ).isPresent() )
56585660
{
56595661
// Override the notimestamp option if a Reproducible Build is requested.
56605662
notimestamp = true;

0 commit comments

Comments
 (0)