[
https://issues.apache.org/jira/browse/FELIX-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645685#action_12645685
]
Stuart McCulloch commented on FELIX-807:
----------------------------------------
I have not looked at this closely, but please note that it's a bad idea for a
bundle to export the default package.
This is why Peter explicitly checks the default namespace - probably it should
be a warning, not an error, and
it should definitely allow adding of classes in the default namespace if you're
_not_ going to export them.
but exporting of classes in the default namespace should definitely be flagged,
so your patch isn't quite right
if you want to workaround this error, you can tell BND to ignore it and create
the bundle anyway:
<_failok>true</_failok>
BTW, the bundleplugin docs:
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html#ApacheFelixMavenBundlePlugin(BND)-EmbedDependencyandExportPackage
clearly state why you shouldn't use <Export-Package>*</Export-Package> if
you're embedding dependencies,
because you _will_ end up duplicating content, especially when you're embedding
jar files with "inline=false".
if you look at the jar generated by your original pom it contains both the
embedded jar files and their contents,
because the Embed-Dependency instruction tells BND to embed the jars and the
Export-Package instruction
tells it to pull in everything on the compilation classpath (ie. inline all
classfiles)
few other things: I don't think you need the extra bundle:manifest goal, the
Import-Package defaults to * so you
can remove that, and Embed-Dependency takes care of updating Bundle-ClassPath
with any embedded jars.
so you could trim your instructions to something like the following, perhaps:
<instructions>
<_exportcontents>org.hsqldb.*</_exportcontents>
<Embed-Dependency>*;scope=compile|runtime;type=!pom;inline=false</Embed-Dependency>
<Embed-Directory>target/dependency</Embed-Directory>
<Embed-StripGroup>true</Embed-StripGroup>
<_failok>true</_failok>
</instructions>
> conversion of JAR into bundle fails if there are classes is the default name
> space
> ----------------------------------------------------------------------------------
>
> Key: FELIX-807
> URL: https://issues.apache.org/jira/browse/FELIX-807
> Project: Felix
> Issue Type: Bug
> Components: Maven Bundle Plugin
> Affects Versions: maven-bundle-plugin-1.4.3
> Environment: any
> Reporter: Stefan Franke
> Fix For: maven-bundle-plugin-1.6.0
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> The conversion of JAR into bundle fails if there are classes is the default
> name space, like hsqldb does.
> Try this pom.xml:
> <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/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>bug.maven.plugin</groupId>
> <artifactId>felix-bundle</artifactId>
> <packaging>bundle</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>hsqldb</name>
> <url>http://maven.apache.org</url>
> <build>
> <plugins>
> <plugin>
> <artifactId>maven-dependency-plugin</artifactId>
> <executions>
> <execution>
> <id>copy-dependencies</id>
> <phase>package</phase>
> <goals>
> <goal>copy-dependencies</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <executions>
> <execution>
> <id>bundle-manifest</id>
> <phase>process-classes</phase>
> <goals>
> <goal>manifest</goal>
> </goals>
> </execution>
> </executions>
> <extensions>true</extensions>
> <configuration>
> <manifestLocation>META-INF</manifestLocation>
> <instructions>
>
> <Bundle-ClassPath>target/dependency/hsqldb-1.8.0.7.jar</Bundle-ClassPath>
> <Import-Package>*</Import-Package>
> <Export-Package>*</Export-Package>
>
> <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
> <Embed-Directory>target/dependency</Embed-Directory>
> <Embed-StripGroup>true</Embed-StripGroup>
> </instructions>
> </configuration>
> </plugin>
> </plugins>
> </build>
> <dependencies>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>3.8.1</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>hsqldb</groupId>
> <artifactId>hsqldb</artifactId>
> <version>1.8.0.7</version>
> <scope>compile</scope>
> </dependency>
> </dependencies>
> </project>
> To fix this I suggest a modification inside
> biz.aQute.bndlib.bndlib-0.0.255.jar inside class aQute.lib.osgiProcessor:
> private void analyzeJar(Jar jar, String prefix, Map classSpace,
> Map contained, Map referred, Map uses) throws
> IOException {
> next: for (Iterator r = jar.getResources().keySet().iterator();
> r
> .hasNext();) {
> String path = (String) r.next();
> if (path.startsWith(prefix)) {
> String relativePath =
> path.substring(prefix.length());
> String pack = getPackage(relativePath);
> if (pack != null &&
> !contained.containsKey(pack)) {
> if (!(pack.equals(".") ||
> isMetaData(relativePath))) {
> The last line is the line where the default name space "." is expicit
> excluded. I don't understand why, but for class files it must be enabled. I
> suggest
> if (pack != null &&
> !contained.containsKey(pack)) {
> if (!(pack.equals(".") ||
> realtivePath.endsWith(".class") || isMetaData(relativePath))) {
> to solve this issue.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.