diff --git a/tools/maven-bundle-plugin/changelog.txt b/tools/maven-bundle-plugin/changelog.txt index 38f22300cc..e2b416e68b 100644 --- a/tools/maven-bundle-plugin/changelog.txt +++ b/tools/maven-bundle-plugin/changelog.txt @@ -1,3 +1,8 @@ +Changes from 6.0.0 to 6.1.0 +--------------------------- +* Improvement + * FELIX-6741 Upgrade dependencies for maven-bundle-plugin (bnd 7.3.0 among other updates). See https://github.com/bndtools/bnd/wiki/Changes-in-7.3.0 + Changes from 5.1.9 to 6.0.0 --------------------------- * Improvement diff --git a/tools/maven-bundle-plugin/pom.xml b/tools/maven-bundle-plugin/pom.xml index ff08badc82..c724caa31a 100644 --- a/tools/maven-bundle-plugin/pom.xml +++ b/tools/maven-bundle-plugin/pom.xml @@ -168,28 +168,33 @@ org.osgi - org.osgi.core - 6.0.0 + osgi.core + 8.0.0 + + + org.apache.felix + org.apache.felix.metatype + 1.2.4 biz.aQute.bnd biz.aQute.bndlib - 7.0.0 + 7.3.0 org.slf4j slf4j-api - 1.7.25 + 2.0.17 org.apache.felix org.apache.felix.bundlerepository - 1.6.6 + 2.0.10 org.apache.felix org.apache.felix.utils - 1.6.0 + 1.11.8 org.apache.maven @@ -218,17 +223,17 @@ org.apache.maven.reporting maven-reporting-api - 3.0 + 4.0.0 org.apache.maven maven-archiver - 3.5.2 + 3.6.3 org.apache.maven.shared maven-dependency-tree - 3.0 + 3.3.0 org.codehaus.plexus @@ -248,17 +253,17 @@ org.apache.maven.doxia doxia-sink-api - 1.0 + 2.1.0 org.apache.maven.doxia doxia-site-renderer - 1.0 + 2.1.0 org.apache.maven.plugin-tools maven-plugin-annotations - 3.4 + 3.15.1 provided @@ -276,7 +281,7 @@ junit junit - 4.13.1 + 4.13.2 test diff --git a/tools/maven-bundle-plugin/src/it/proxy-interface-import/bundle/pom.xml b/tools/maven-bundle-plugin/src/it/proxy-interface-import/bundle/pom.xml new file mode 100644 index 0000000000..cb1b2560cb --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/proxy-interface-import/bundle/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + org.apache.felix.bundleits + proxy-interface-import + 1-SNAPSHOT + + proxy-interface-import-bundle + bundle + + + + org.apache.felix.bundleits + proxy-interface-import-provider + 1-SNAPSHOT + + + + + + + org.apache.felix + maven-bundle-plugin + ${mbp.version} + true + + + org.apache.felix.proxy.client + + + + + + diff --git a/tools/maven-bundle-plugin/src/it/proxy-interface-import/bundle/src/main/java/org/apache/felix/proxy/client/Client.java b/tools/maven-bundle-plugin/src/it/proxy-interface-import/bundle/src/main/java/org/apache/felix/proxy/client/Client.java new file mode 100644 index 0000000000..5514f45a9b --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/proxy-interface-import/bundle/src/main/java/org/apache/felix/proxy/client/Client.java @@ -0,0 +1,38 @@ +/* + * 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.proxy.client; + +import java.lang.reflect.Proxy; + +import org.apache.felix.proxy.api.Greeting; + +/** + * Creates a dynamic proxy for {@link Greeting}. This class only references the Greeting interface + * (via the {@code Greeting.class} literal); it never references org.apache.felix.proxy.model + * directly. That package therefore appears in Import-Package only because bnd (7.2.0+) inspects + * the method signatures of interfaces passed to Proxy.newProxyInstance. + */ +public class Client { + public Greeting create() { + return (Greeting) Proxy.newProxyInstance( + Client.class.getClassLoader(), + new Class[] { Greeting.class }, + (proxy, method, args) -> null); + } +} diff --git a/tools/maven-bundle-plugin/src/it/proxy-interface-import/pom.xml b/tools/maven-bundle-plugin/src/it/proxy-interface-import/pom.xml new file mode 100644 index 0000000000..234dff9609 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/proxy-interface-import/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + org.apache.felix.bundleits + proxy-interface-import + 1-SNAPSHOT + pom + + + + + @project.version@ + 17 + UTF-8 + + + + provider + bundle + + diff --git a/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/pom.xml b/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/pom.xml new file mode 100644 index 0000000000..9edecb110c --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + org.apache.felix.bundleits + proxy-interface-import + 1-SNAPSHOT + + proxy-interface-import-provider + + jar + diff --git a/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/src/main/java/org/apache/felix/proxy/api/Greeting.java b/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/src/main/java/org/apache/felix/proxy/api/Greeting.java new file mode 100644 index 0000000000..a00032caf9 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/src/main/java/org/apache/felix/proxy/api/Greeting.java @@ -0,0 +1,30 @@ +/* + * 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.proxy.api; + +import org.apache.felix.proxy.model.Message; + +/** + * Proxied interface. Its single method references {@link Message}, which lives in a different + * package. The bundle under test only references this interface via a class literal, so the + * Message package can reach Import-Package solely through bnd's Proxy.newProxyInstance detection. + */ +public interface Greeting { + Message greet(); +} diff --git a/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/src/main/java/org/apache/felix/proxy/model/Message.java b/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/src/main/java/org/apache/felix/proxy/model/Message.java new file mode 100644 index 0000000000..db9790536c --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/proxy-interface-import/provider/src/main/java/org/apache/felix/proxy/model/Message.java @@ -0,0 +1,28 @@ +/* + * 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.proxy.model; + +/** + * Referenced only from {@link org.apache.felix.proxy.api.Greeting}'s method signature. + */ +public class Message { + public String text() { + return "hello"; + } +} diff --git a/tools/maven-bundle-plugin/src/it/proxy-interface-import/verify.groovy b/tools/maven-bundle-plugin/src/it/proxy-interface-import/verify.groovy new file mode 100644 index 0000000000..0d96dad383 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/proxy-interface-import/verify.groovy @@ -0,0 +1,35 @@ +/* + * 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.util.jar.Manifest + +// Parse with java.util.jar.Manifest so that 72-column line folding is handled for us. +Manifest manifest = new File(basedir, "bundle/target/classes/META-INF/MANIFEST.MF").withInputStream { new Manifest(it) } +String importPackage = manifest.mainAttributes.getValue("Import-Package") +assert importPackage != null : "Bundle has no Import-Package header" + +// Sanity check: the interface's own package is imported (referenced via the Greeting.class literal). +assert importPackage.contains("org.apache.felix.proxy.api") : + "Expected the proxied interface's package to be imported. Import-Package was: " + importPackage + +// The actual assertion: the package used only by Greeting's method signature is imported because +// bnd (7.2.0+) inspects the methods of interfaces passed to Proxy.newProxyInstance. +// See https://github.com/bndtools/bnd/wiki/Changes-in-7.2.0 (-noproxyinterfaces disables this). +assert importPackage.contains("org.apache.felix.proxy.model") : + "Expected the proxy interface's method-signature package (org.apache.felix.proxy.model) " + + "to be imported via Proxy.newProxyInstance detection. Import-Package was: " + importPackage diff --git a/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/pom.xml b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/pom.xml new file mode 100644 index 0000000000..5b4209ce89 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + org.apache.felix.bundleits + unversioned-export-package-still-imported + 1-SNAPSHOT + bundle + + + + org.apache.maven.plugins + maven-compiler-plugin + + 17 + 17 + + + + org.apache.felix + maven-bundle-plugin + @project.version@ + true + + + org.apache.felix.test1,org.apache.felix.test2;version="1-SNAPSHOT" + org.apache.felix.test1,org.apache.felix.test2 + + + + + + diff --git a/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/src/main/java/org/apache/felix/test1/Dummy.java b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/src/main/java/org/apache/felix/test1/Dummy.java new file mode 100644 index 0000000000..30f4f42293 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/src/main/java/org/apache/felix/test1/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.test1; +public class Dummy { +} \ No newline at end of file diff --git a/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/src/main/java/org/apache/felix/test2/Dummy2.java b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/src/main/java/org/apache/felix/test2/Dummy2.java new file mode 100644 index 0000000000..90e34e9370 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/src/main/java/org/apache/felix/test2/Dummy2.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.test2; +public class Dummy2 { +} \ No newline at end of file diff --git a/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/verify.groovy b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/verify.groovy new file mode 100644 index 0000000000..3fbef40033 --- /dev/null +++ b/tools/maven-bundle-plugin/src/it/unversioned-export-package-still-imported/verify.groovy @@ -0,0 +1,35 @@ +/* + * 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("Import-Package") && !line.contains("org.apache.felix.test1")) { + // See https://github.com/bndtools/bnd/pull/6270 + // bnd 7.3.0 by default would not add this to the Import-Package, as the version range is not specified + // the maven-bundle-plugin doesn't have this issue, as a default version is added to the Export-Package statement + // automatically if missing + throw new Exception("Unversioned Export-Package statements should also be added to Import-Package statements, as maven-bundle-plugin adds a default version (1.0.0)"); + } + if (line.contains("Import-Package") && !line.contains("org.apache.felix.test2;version=")) { + throw new Exception("Versioned Export-Package should be part of the Import-Package, as it contains an explicit version range"); + } +} + + 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 index 54aa86f9a3..24adf082dc 100644 --- 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 @@ -20,7 +20,7 @@ String manifest = new File( basedir, "target/classes/META-INF/MANIFEST.MF" ).tex assert !manifest.isEmpty() manifest.eachLine() { line -> - if (line.contains("Tool") && !line.contains("7.0.0")) { + if (line.contains("Tool") && !line.contains("7.3.0")) { throw new Exception("Wrong bnd version used"); } if (line.contains("Embedded-Artifacts") && !line.contains("jersey-server-3.1.7.jar")) { 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 295530f8d7..6c8b01e57b 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 @@ -550,8 +550,7 @@ protected Builder getOSGiBuilder( MavenProject currentProject, Map