From 969a5d30c2368518269ba46d3c4583b3de3321e1 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 8 May 2024 18:31:40 +0200 Subject: [PATCH 1/9] Update pom.xml --- http/samples/whiteboard/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/samples/whiteboard/pom.xml b/http/samples/whiteboard/pom.xml index d17d2c432d..f82047bc35 100644 --- a/http/samples/whiteboard/pom.xml +++ b/http/samples/whiteboard/pom.xml @@ -96,7 +96,7 @@ org.apache.felix org.apache.felix.http.jetty12 - 1.0.5-SNAPSHOT + 1.0.7-SNAPSHOT provided From d4b2b08136b980102ab21e10e76fec8f59eaf09c Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 25 May 2024 18:12:30 +0200 Subject: [PATCH 2/9] Update bnd to 7.0.0 To be able to handle Multi-Release jars as dependencies in an OSGi bundle. This prevents exceptions like: ``` build 24-May-2024 18:40:01 [ERROR] Bundle com.abc:jersey-bundle:bundle:55.0-SNAPSHOT : Classes found in the wrong directory: {META-INF/versions/21/org/glassfish/jersey/innate/VirtualThreadSupport$NonLoomishExecutors.class=org.glassfish.jersey.innate.VirtualThreadSupport$NonLoomishExecutors, META-INF/versions/21/org/glassfish/jersey/innate/virtual/LoomishExecutors.class=org.glassfish.jersey.innate.virtual.LoomishExecutors, META-INF/versions/21/org/glassfish/jersey/innate/VirtualThreadSupport$Java21LoomishExecutors.class=org.glassfish.jersey.innate.VirtualThreadSupport$Java21LoomishExecutors, META-INF/versions/21/org/glassfish/jersey/innate/VirtualThreadSupport.class=org.glassfish.jersey.innate.VirtualThreadSupport} ``` --- tools/maven-bundle-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/maven-bundle-plugin/pom.xml b/tools/maven-bundle-plugin/pom.xml index 5f037fed60..c991895043 100644 --- a/tools/maven-bundle-plugin/pom.xml +++ b/tools/maven-bundle-plugin/pom.xml @@ -174,7 +174,7 @@ biz.aQute.bnd biz.aQute.bndlib - 6.3.1 + 7.0.0 org.slf4j From 93b43b7b661308f7669182a18aa4adc926684236 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 25 May 2024 18:16:27 +0200 Subject: [PATCH 3/9] Update pom.xml Update to java 17 as thats required by bnd --- tools/maven-bundle-plugin/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/maven-bundle-plugin/pom.xml b/tools/maven-bundle-plugin/pom.xml index c991895043..64f249db3d 100644 --- a/tools/maven-bundle-plugin/pom.xml +++ b/tools/maven-bundle-plugin/pom.xml @@ -137,8 +137,8 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 + 17 + 17 From efc79a71b26ca47e93eab75397bc38d881639163 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 25 May 2024 18:39:05 +0200 Subject: [PATCH 4/9] Update pom.xml Revert unneeded change --- http/samples/whiteboard/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/samples/whiteboard/pom.xml b/http/samples/whiteboard/pom.xml index f82047bc35..d17d2c432d 100644 --- a/http/samples/whiteboard/pom.xml +++ b/http/samples/whiteboard/pom.xml @@ -96,7 +96,7 @@ org.apache.felix org.apache.felix.http.jetty12 - 1.0.7-SNAPSHOT + 1.0.5-SNAPSHOT provided From 065c1cc2466b93c9080819a59ff8ebdc41ce63b5 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 25 May 2024 22:14:31 +0200 Subject: [PATCH 5/9] Remove fixupmessages --- .../felix/bundleplugin/BundlePlugin.java | 30 ------------------- 1 file changed, 30 deletions(-) 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 1bd7f365b4..7c54ba1b75 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 @@ -708,9 +708,6 @@ protected void addMavenInstructions(MavenProject currentProject, Builder builder // update BND instructions to add included Maven resources includeMavenResources(currentProject, builder, getLog()); - // Fixup error messages - includeJava9Fixups(currentProject, builder); - // calculate default export/private settings based on sources addLocalPackages(outputDirectory, builder); @@ -2224,33 +2221,6 @@ else if ( mavenSourcePaths.length() > 0 ) } } - /** - * Downgrade the message "Classes found in the wrong directory" to a warning. This allows the plugin - * to process a multi-release JAR (see JEP 238, http://openjdk.java.net/jeps/238). - * - * Note that the version-specific paths will NOT be visible at runtime nor processed by bnd for - * imported packages etc. This will not be possible until a runtime solution for multi-release - * JARs exists in OSGi. This fix only allows these JARs to be processed at all and to be usable on - * Java 8 (and below), and also on Java 9 where the version-specific customizations are optional. - */ - protected static void includeJava9Fixups(MavenProject currentProject, Analyzer analyzer) - { - final String classesInWrongDirError = "Classes found in the wrong directory"; - final String newFixup = "Classes found in the wrong directory;" - + Analyzer.FIXUPMESSAGES_IS_DIRECTIVE + "=" - + Analyzer.FIXUPMESSAGES_IS_WARNING; - - String fixups = analyzer.getProperty(Analyzer.FIXUPMESSAGES); - if (fixups != null && !fixups.isEmpty()) { - if (!fixups.contains(classesInWrongDirError)) { - fixups += "," + newFixup; - } - } else { - fixups = newFixup; - } - analyzer.setProperty(Analyzer.FIXUPMESSAGES, fixups); - } - static class ClassPathItem { final String id; final File file; From 626778537323671796115d4239cddd5995d72593 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 25 May 2024 22:17:12 +0200 Subject: [PATCH 6/9] Remove fixup test --- .../felix/bundleplugin/BundlePluginTest.java | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java b/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java index 6eaa2ef7b1..a6d5ced631 100644 --- a/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java +++ b/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java @@ -414,25 +414,6 @@ public void testPropertySanitizing() throws Exception File file = new File( getBasedir(), "target" + File.separatorChar + "test.props" ); builder.getProperties().store( new FileOutputStream( file ), "TEST" ); - } - - public void testIncludeJava9Fixups() { - Builder analyzer = new Builder(); - - MavenProject project = getMavenProjectStub(); - BundlePlugin.includeJava9Fixups(project, analyzer); - - assertEquals("Classes found in the wrong directory;is:=warning", analyzer.get("-fixupmessages")); - } - - public void testOverrideJava9Fixups() { - Builder analyzer = new Builder(); - - MavenProject project = getMavenProjectStub(); - analyzer.set("-fixupmessages", "Classes found in the wrong directory;is:=error"); - BundlePlugin.includeJava9Fixups(project, analyzer); - - assertEquals("Classes found in the wrong directory;is:=error", analyzer.get("-fixupmessages")); - } + } } From 3d7a035f27b006001c5695060dbcead1e6b44341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20R=C3=BCtter?= Date: Thu, 30 May 2024 14:08:11 +0200 Subject: [PATCH 7/9] Fix error with conversion --- .../main/java/org/apache/felix/bundleplugin/ManifestPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 42dd7a16cc..bb0f3028c8 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 @@ -323,7 +323,7 @@ protected Analyzer getAnalyzer( MavenProject project, Map instru 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.getJar().setReproducible(analyzer.getProperties().getProperty( Constants.REPRODUCIBLE ) ); analyzer.mergeManifest( analyzer.getJar().getManifest() ); analyzer.getJar().setManifest( analyzer.calcManifest() ); From 15ac25827084f0e2a5584235072a6b1127f08c56 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 3 Jun 2024 19:42:24 +0200 Subject: [PATCH 8/9] Add noimportjava instruction + + + <_noimportjava>true + + --- .../src/it/no-test-scoped-imports/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/maven-bundle-plugin/src/it/no-test-scoped-imports/pom.xml b/tools/maven-bundle-plugin/src/it/no-test-scoped-imports/pom.xml index 3a15568ced..2eedf2350c 100644 --- a/tools/maven-bundle-plugin/src/it/no-test-scoped-imports/pom.xml +++ b/tools/maven-bundle-plugin/src/it/no-test-scoped-imports/pom.xml @@ -53,6 +53,11 @@ under the License. maven-bundle-plugin @project.version@ true + + + <_noimportjava>true + + From f77d08789d48aa2da5172959670a80f6916d089b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20R=C3=BCtter?= Date: Tue, 4 Jun 2024 11:22:10 +0200 Subject: [PATCH 9/9] Add integration test that includes multi-release jar and validates a proper manifest is created with bnd 7.0.0 --- .../src/it/with-multi-release-jar/pom.xml | 72 +++++++++++++++++++ .../java/org/apache/felix/test/Dummy.java | 21 ++++++ .../it/with-multi-release-jar/verify.groovy | 31 ++++++++ 3 files changed, 124 insertions(+) create mode 100644 tools/maven-bundle-plugin/src/it/with-multi-release-jar/pom.xml create mode 100644 tools/maven-bundle-plugin/src/it/with-multi-release-jar/src/main/java/org/apache/felix/test/Dummy.java create mode 100644 tools/maven-bundle-plugin/src/it/with-multi-release-jar/verify.groovy diff --git a/tools/maven-bundle-plugin/src/it/with-multi-release-jar/pom.xml b/tools/maven-bundle-plugin/src/it/with-multi-release-jar/pom.xml new file mode 100644 index 0000000000..cbd30a0e36 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/with-multi-release-jar/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + org.apache.felix.bundleits + with-multi-release-jar + 1-SNAPSHOT + bundle + + + + + org.glassfish.jersey + jersey-bom + 3.1.7 + pom + + + + + + + + org.glassfish.jersey.core + jersey-server + 3.1.7 + compile + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 17 + 17 + + + + org.apache.felix + maven-bundle-plugin + @project.version@ + true + + + *;scope=compile + true + + + + + + diff --git a/tools/maven-bundle-plugin/src/it/with-multi-release-jar/src/main/java/org/apache/felix/test/Dummy.java b/tools/maven-bundle-plugin/src/it/with-multi-release-jar/src/main/java/org/apache/felix/test/Dummy.java new file mode 100644 index 0000000000..e008adaa95 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/with-multi-release-jar/src/main/java/org/apache/felix/test/Dummy.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +package org.apache.felix.test; +public class Dummy { +} \ No newline at end of file diff --git a/tools/maven-bundle-plugin/src/it/with-multi-release-jar/verify.groovy b/tools/maven-bundle-plugin/src/it/with-multi-release-jar/verify.groovy new file mode 100644 index 0000000000..54aa86f9a3 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/with-multi-release-jar/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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.isEmpty() + +manifest.eachLine() { line -> + if (line.contains("Tool") && !line.contains("7.0.0")) { + throw new Exception("Wrong bnd version used"); + } + if (line.contains("Embedded-Artifacts") && !line.contains("jersey-server-3.1.7.jar")) { + throw new Exception("The multi release jar is not properly embedded"); + } +} + +