You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/07/07 17:58:42 UTC

[maven-javadoc-plugin] branch master updated: Add Integration Test for reproducible builds

This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new bacc078f Add Integration Test for reproducible builds
bacc078f is described below

commit bacc078f88b29dbdfc4fc8e31a86717a59c4e3b6
Author: Jorge Solórzano <jo...@gmail.com>
AuthorDate: Mon Jul 4 11:46:37 2022 +0200

    Add Integration Test for reproducible builds
    
    Signed-off-by: Jorge Solórzano <jo...@gmail.com>
---
 src/it/projects/reproducible/invoker.properties    | 17 ++++++
 src/it/projects/reproducible/pom.xml               | 45 +++++++++++++++
 .../reproducible/src/main/java/foo/Bar.java        | 35 ++++++++++++
 src/it/projects/reproducible/verify.groovy         | 65 ++++++++++++++++++++++
 4 files changed, 162 insertions(+)

diff --git a/src/it/projects/reproducible/invoker.properties b/src/it/projects/reproducible/invoker.properties
new file mode 100644
index 00000000..80190f7e
--- /dev/null
+++ b/src/it/projects/reproducible/invoker.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+invoker.goals = compile javadoc:jar
diff --git a/src/it/projects/reproducible/pom.xml b/src/it/projects/reproducible/pom.xml
new file mode 100644
index 00000000..32569ee6
--- /dev/null
+++ b/src/it/projects/reproducible/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>foo</groupId>
+  <artifactId>bar</artifactId>
+  <version>0.1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
+    <maven.compiler.target>@maven.compiler.target@</maven.compiler.target>
+    <project.build.outputTimestamp>2020-02-29T23:59:58Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/reproducible/src/main/java/foo/Bar.java b/src/it/projects/reproducible/src/main/java/foo/Bar.java
new file mode 100644
index 00000000..e83ea227
--- /dev/null
+++ b/src/it/projects/reproducible/src/main/java/foo/Bar.java
@@ -0,0 +1,35 @@
+package foo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Bar.
+ */
+public class Bar
+{
+    /**
+     * Print "Bar".
+     */
+    public void run()
+    {
+        System.out.println( "Bar" );
+    }
+
+}
diff --git a/src/it/projects/reproducible/verify.groovy b/src/it/projects/reproducible/verify.groovy
new file mode 100644
index 00000000..83d30ed8
--- /dev/null
+++ b/src/it/projects/reproducible/verify.groovy
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.nio.file.attribute.FileTime;
+import java.time.Instant;
+import java.util.jar.*;
+
+def target = new File( basedir, 'target' )
+assert target.isDirectory()
+
+def apidocs = new File( target, 'apidocs' )
+assert apidocs.isDirectory()
+
+def options = new File( apidocs, 'options' )
+assert options.isFile()
+assert options.text.contains( "'Copyright &#169; 2020. All rights reserved.'" )
+
+def artifact = new File( target, 'bar-0.1.0-SNAPSHOT-javadoc.jar' )
+assert artifact.isFile()
+
+// notimestamp in html files
+apidocs.eachFileRecurse
+{
+    if ( it.name.endsWith( '.html' ) )
+    {
+        assert it.text =~ /<!-- Generated by javadoc (\(\d+\) )?-->/
+    }
+}
+
+// Normalize to UTC
+long normalizeUTC( String timestamp )
+{
+  long millis = Instant.parse( timestamp ).toEpochMilli()
+  Calendar cal = Calendar.getInstance()
+  cal.setTimeInMillis( millis )
+  return millis - ( cal.get( Calendar.ZONE_OFFSET ) + cal.get( Calendar.DST_OFFSET ) )
+}
+
+JarFile jar = new JarFile( artifact )
+
+// 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()