Skip to content

Commit bacc078

Browse files
jorsolslawekjaranowski
authored andcommitted
Add Integration Test for reproducible builds
Signed-off-by: Jorge Solórzano <[email protected]>
1 parent 497f80f commit bacc078

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
invoker.goals = compile javadoc:jar

src/it/projects/reproducible/pom.xml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>foo</groupId>
26+
<artifactId>bar</artifactId>
27+
<version>0.1.0-SNAPSHOT</version>
28+
29+
<properties>
30+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
31+
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
32+
<maven.compiler.target>@maven.compiler.target@</maven.compiler.target>
33+
<project.build.outputTimestamp>2020-02-29T23:59:58Z</project.build.outputTimestamp>
34+
</properties>
35+
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.apache.maven.plugins</groupId>
40+
<artifactId>maven-javadoc-plugin</artifactId>
41+
<version>@project.version@</version>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package foo;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* Bar.
24+
*/
25+
public class Bar
26+
{
27+
/**
28+
* Print "Bar".
29+
*/
30+
public void run()
31+
{
32+
System.out.println( "Bar" );
33+
}
34+
35+
}
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import java.nio.file.attribute.FileTime;
21+
import java.time.Instant;
22+
import java.util.jar.*;
23+
24+
def target = new File( basedir, 'target' )
25+
assert target.isDirectory()
26+
27+
def apidocs = new File( target, 'apidocs' )
28+
assert apidocs.isDirectory()
29+
30+
def options = new File( apidocs, 'options' )
31+
assert options.isFile()
32+
assert options.text.contains( "'Copyright &#169; 2020. All rights reserved.'" )
33+
34+
def artifact = new File( target, 'bar-0.1.0-SNAPSHOT-javadoc.jar' )
35+
assert artifact.isFile()
36+
37+
// notimestamp in html files
38+
apidocs.eachFileRecurse
39+
{
40+
if ( it.name.endsWith( '.html' ) )
41+
{
42+
assert it.text =~ /<!-- Generated by javadoc (\(\d+\) )?-->/
43+
}
44+
}
45+
46+
// Normalize to UTC
47+
long normalizeUTC( String timestamp )
48+
{
49+
long millis = Instant.parse( timestamp ).toEpochMilli()
50+
Calendar cal = Calendar.getInstance()
51+
cal.setTimeInMillis( millis )
52+
return millis - ( cal.get( Calendar.ZONE_OFFSET ) + cal.get( Calendar.DST_OFFSET ) )
53+
}
54+
55+
JarFile jar = new JarFile( artifact )
56+
57+
// All entries should have the same timestamp
58+
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()

0 commit comments

Comments
 (0)