Jay Huang
Jay Huang

Reputation: 119

How to make maven bundlor to use my MANIFEST.MF instead of using a template and types detection?

I am developing an OSGi app with Virgo, and using maven bundlor to build the bundles. I want to use my MANIFEST.MF used by Virgo which includes bundle imports and a few package imports, but bundlor auto detects the classes used by my bundle and generates packages imports for them including the ones from the bundles in Import-Bundle header.

Is there a way to tell bundlor just use my already built MANIFEST.MF or disable the java type auto detection?

Upvotes: 0

Views: 913

Answers (1)

eis
eis

Reputation: 53543

Well, just don't use bundlor then? Like said in the documentation, "Bundlor's main function is to scan an existing JAR file and determine its runtime dependencies.",

For example, with maven-bundle-plugin (in this example, I have a .war file, but that shouldn't matter)

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <archive>
          <!-- add the generated manifest to the war -->
          <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
        </archive>
        <failOnMissingWebXml>true</failOnMissingWebXml>
        <packagingExcludes>WEB-INF/web.xml</packagingExcludes>  
    </configuration>
</plugin>
<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <executions>
      <execution>
        <id>bundle-manifest</id>
        <phase>process-classes</phase>
        <goals>
          <goal>manifest</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
        <supportedProjectTypes>
          <supportedProjectType>jar</supportedProjectType>
          <supportedProjectType>bundle</supportedProjectType>
          <supportedProjectType>war</supportedProjectType>
        </supportedProjectTypes>
        <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath>
            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
            <Embed-Directory>WEB-INF/lib</Embed-Directory>
            <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
            <Embed-Transitive>true</Embed-Transitive>
            <Import-Package>
              javax.annotation,
              javax.servlet;version="[2.5,3.0]",
              javax.servlet.http;version="[2.5,3.0]",
              org.osgi.service.http,
              org.osgi.service.packageadmin,
              org.osgi.framework;version="[1.5,2.0)",
              org.jboss.logging;version="[3.0,4.0)"
            </Import-Package>
            <Private-Package>fi.eis.applications</Private-Package>
            <Web-ContextPath>/spring-app</Web-ContextPath>  
        </instructions>
    </configuration>
</plugin>

I could've left the maven-bundle-plugin also undefined and just placed a manifest file in WEB-INF.

Upvotes: 4

Related Questions