Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FELIX-6708 upgrade bnd to 7.0.0 #322

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tools/maven-bundle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -174,7 +174,7 @@
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>biz.aQute.bndlib</artifactId>
<version>6.3.1</version>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ under the License.
<artifactId>maven-bundle-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_noimportjava>true</_noimportjava>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
72 changes: 72 additions & 0 deletions tools/maven-bundle-plugin/src/it/with-multi-release-jar/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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>with-multi-release-jar</artifactId>
<version>1-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey/jersey-bom -->
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>3.1.7</version>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server -->
<!-- this is a multi-release jar -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>3.1.7</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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");
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ protected Analyzer getAnalyzer( MavenProject project, Map<String, String> 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() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}

}