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

Building OSGi bundles with maven-bundle-plugin results in "Error reading Bundle-SymbolicName from OSGi manifest file" #197

Open
holgerknoche opened this issue Apr 26, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@holgerknoche
Copy link

Consider the following multi-module Maven project. One module is an OSGi bundle built with the maven-bundle-plugin. The other module is a CICS bundle that includes the OSGi bundle. Building the entire project with "mvn compile" fails with the error message "Error reading Bundle-SymbolicName from OSGi manifest file". Building it with "mvn package" or "mvn install" works fine.
The maven-bundle-plugin creates the bundle manifest after compilation (in the process-classes phase), as it inspects the class files to determine which packages to import and export. Maybe the check for the symbolic name could be moved so that it is only executed when an actual packaging occurs.

@jsventura
Copy link

jsventura commented Feb 9, 2023

Hi @holgerknoche, how do you solve this problem ?

@ind1go ind1go added the bug Something isn't working label Feb 9, 2023
@holgerknoche
Copy link
Author

Hi @jsventura, we actually just avoid building the projects with "mvn compile". Since the goals we really need are "package" and "install" and those work fine, this issue is not really a problem for us. Maybe it would be enough to move the goal from the "compile" phase to the "package" phase, but I have not tried this yet.

@stewartfrancis
Copy link
Member

stewartfrancis commented Feb 18, 2023

I've been able to reproduce this, and I'm pretty sure it's to do with our default lifecycle bindings when you're using the cics-bundle packaging type. I'll work on a fix for this to build the bundle as late as possible in reactor builds, probably changing the binding for all plugins to the package phase but that will require a new plugin major version. Also not been able to quite get that working yet.

In the mean time I was able to work around this by changing the phase bound to the bundle plugin's build goal:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>stewf</groupId>
    <artifactId>parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>cics</artifactId>
  
  <packaging>cics-bundle</packaging>
  
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>osgi</artifactId>
      <version>${project.version}</version>
      <type>jar</type>
    </dependency>
  </dependencies>
  
  <build>
    <plugins>
      <plugin>
        <groupId>com.ibm.cics</groupId>
        <artifactId>cics-bundle-maven-plugin</artifactId>
        <version>1.0.3</version>
        <extensions>true</extensions>
        <configuration>
          <jvmserver>asdf</jvmserver>
        </configuration>
        <executions>
          <execution>
            <id>default-build</id> <!-- You must set this execution ID for this to work -->
            <phase>package</phase> <!-- rebind the default execution to the package phase -->
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  
</project>

Note that the latest phase you'll be able to run this in at the moment is package without also changing the lifecycle phase of the cics bundle package plugin too. I can explain further if that's useful, but hopefully that's not an issue for you.

I'll put together something to address the default lifecycle phase in a future release of the plugin, hopefully you can make do with the workaround for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants