This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 2ee99c9 [FELIX-6495] fix BND inconsistency for reproducibility in BND
new cb0c9d7 Merge pull request #126 from hboutemy/master
2ee99c9 is described below
commit 2ee99c9f1a319127e93374bc6eb128aeab25cc87
Author: Hervé Boutemy <[email protected]>
AuthorDate: Thu Dec 30 17:46:53 2021 +0100
[FELIX-6495] fix BND inconsistency for reproducibility in BND
---
.../src/it/reproducible-manifest/pom.xml | 70 ++++++++++++++++++++++
.../src/it/reproducible-manifest/verify.groovy | 27 +++++++++
.../apache/felix/bundleplugin/BundlePlugin.java | 3 +-
.../apache/felix/bundleplugin/ManifestPlugin.java | 6 +-
4 files changed, 104 insertions(+), 2 deletions(-)
diff --git a/tools/maven-bundle-plugin/src/it/reproducible-manifest/pom.xml
b/tools/maven-bundle-plugin/src/it/reproducible-manifest/pom.xml
new file mode 100644
index 0000000..def3e69
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/reproducible-manifest/pom.xml
@@ -0,0 +1,70 @@
+<?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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.felix.bundleits</groupId>
+ <artifactId>reproducible</artifactId>
+ <version>1-SNAPSHOT</version>
+ <!-- default packaging: jar -->
+
+ <properties>
+ <project.build.outputTimestamp>1</project.build.outputTimestamp>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>1.19</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/tools/maven-bundle-plugin/src/it/reproducible-manifest/verify.groovy
b/tools/maven-bundle-plugin/src/it/reproducible-manifest/verify.groovy
new file mode 100644
index 0000000..08c1c4b
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/reproducible-manifest/verify.groovy
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+String manifest = new File( basedir, "target/classes/META-INF/MANIFEST.MF"
).text;
+
+assert !manifest.contains( "Build-Jdk:" )
+assert manifest.contains( "Build-Jdk-Spec:" )
+
+assert !manifest.contains( "Build-By:" )
+
+assert !manifest.contains( "Bnd-LastModified:" )
diff --git
a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 3a8117f..ded0834 100644
---
a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++
b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -470,6 +470,7 @@ public class BundlePlugin extends AbstractMojo
}
// attach bundle to maven project
+ getLog().info("Building bundle: " + jarFile.getPath());
jarFile.getParentFile().mkdirs();
builder.getJar().write( jarFile );
@@ -545,7 +546,7 @@ public class BundlePlugin extends AbstractMojo
if ( new MavenArchiver().parseOutputTimestamp( outputTimestamp ) !=
null )
{
- properties.put( "-reproducible", "true" );
+ properties.put( Constants.REPRODUCIBLE, "true" );
}
// process overrides from project
diff --git
a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index b15c26b..e47e3fe 100644
---
a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++
b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -47,6 +47,7 @@ import java.util.zip.ZipFile;
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.Builder;
+import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Instructions;
import aQute.bnd.osgi.Jar;
import aQute.bnd.osgi.Resource;
@@ -318,6 +319,9 @@ public class ManifestPlugin extends BundlePlugin
}
else
{
+ // FELIX-6495: workaround BND inconsistency: internal jar does not
take "-reproducible" flag into account...
+ analyzer.getJar().setReproducible( "true".equals(
analyzer.getProperties().getProperty( Constants.REPRODUCIBLE ) ) );
+
analyzer.mergeManifest( analyzer.getJar().getManifest() );
analyzer.getJar().setManifest( analyzer.calcManifest() );
}
@@ -494,7 +498,7 @@ public class ManifestPlugin extends BundlePlugin
public static void writeManifest( Manifest manifest, File outputFile,
boolean niceManifest,
BuildContext buildContext, Log log ) throws IOException
{
- log.debug("Write manifest to " + outputFile.getPath());
+ log.info("Writing manifest: " + outputFile.getPath());
outputFile.getParentFile().mkdirs();
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() )