Skip to content

Commit 5628713

Browse files
committed
FELIX-6741-Upgrade-dependencies-for-maven-bundle-plugin
- Add integration test for Export-Package / Import-Package, based on bndtools/bnd#6270 - This is backwards compatible, as maven-bundle-plugin automatically adds a version for all Export-Package statements if not specified (1.0.0) These instructions: ``` <Export-Package>org.apache.felix.test1,org.apache.felix.test2;version="1-SNAPSHOT"</Export-Package> <Import-Package>org.apache.felix.test1,org.apache.felix.test2</Import-Package> ``` Lead to these manifest entries: ``` Export-Package: org.apache.felix.test1;version="1.0.0",org.apache.felix. test2;version="1.0.0.SNAPSHOT" Import-Package: org.apache.felix.test1,org.apache.felix.test2;version="[ 1.0,2)" ```
1 parent 4556b12 commit 5628713

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
<groupId>org.apache.felix.bundleits</groupId>
24+
<artifactId>unversioned-export-package-still-imported</artifactId>
25+
<version>1-SNAPSHOT</version>
26+
<packaging>bundle</packaging>
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-compiler-plugin</artifactId>
32+
<configuration>
33+
<source>17</source>
34+
<target>17</target>
35+
</configuration>
36+
</plugin>
37+
<plugin>
38+
<groupId>org.apache.felix</groupId>
39+
<artifactId>maven-bundle-plugin</artifactId>
40+
<version>@project.version@</version>
41+
<extensions>true</extensions>
42+
<configuration>
43+
<instructions>
44+
<Export-Package>org.apache.felix.test1,org.apache.felix.test2;version="1-SNAPSHOT"</Export-Package>
45+
<Import-Package>org.apache.felix.test1,org.apache.felix.test2</Import-Package>
46+
</instructions>
47+
</configuration>
48+
</plugin>
49+
</plugins>
50+
</build>
51+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.felix.test1;
20+
public class Dummy {
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.felix.test2;
20+
public class Dummy2 {
21+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
String manifest = new File( basedir, "target/classes/META-INF/MANIFEST.MF" ).text
20+
assert !manifest.isEmpty()
21+
22+
manifest.eachLine() { line ->
23+
if (line.contains("Import-Package") && !line.contains("org.apache.felix.test1")) {
24+
// See https://github.com/bndtools/bnd/pull/6270
25+
// bnd 7.1.0 by default would not add this to the Import-Package, as the version range is not specified
26+
// the maven-bundle-plugin doesn't have this issue, as a default version is added to the Export-Package statement
27+
// automatically if missing
28+
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)");
29+
}
30+
if (line.contains("Import-Package") && !line.contains("org.apache.felix.test2;version=")) {
31+
throw new Exception("Versioned Export-Package should be part of the Import-Package, as it contains an explicit version range");
32+
}
33+
}
34+
35+

0 commit comments

Comments
 (0)