0

I have some Java/OSGi projects that I wish to build and package as a single Deployment Package.

I'm using Tycho to compile the sources for a particular target-platform, all dependencies are in a local p2 repository.

If I set <packaging>eclipse-plugin</packaging> in my pom.xml the build goes fine but I get a .jar as output.
When I use maven-bundle-plugin and set <packaging>bundle</packaging> the build breaks, because it compiles with the standard maven-compiler-plugin instead of Tycho.

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.5</version>
    <extensions>true</extensions>
    <configuration>
        <manifestLocation>META-INF</manifestLocation>
        <instructions>
            <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
            <Bundle-Name>${project.name}</Bundle-Name>
            <Bundle-Version>${project.version}</Bundle-Version>
            <Import-Package>
                javax.net;resolution:=optional,
                javax.net.ssl;resolution:=optional
            </Import-Package>
            <Export-Package>my.project.package</Export-Package>
        </instructions>
    </configuration>
</plugin>

How do I force the compilation with Tycho? Or is there any other way to do what I need?

oberlies
  • 11,503
  • 4
  • 63
  • 110
Alessandro Da Rugna
  • 4,571
  • 20
  • 40
  • 64
  • If your dependencies are in a P2 repository you're better using Tycho and the `eclipse-plugin` packaging. This will create an OSGi bundle jar for each project. What do you want to do after that? What do you mean by `single Deployment Package`? (zip, P2, some container specific package?) – Nick Wilson Mar 11 '15 at 13:58
  • I want to package many projects (=OSGi bundles) into a single .dp file. [Deployment Package](https://osgi.org/javadoc/r4v42/org/osgi/service/deploymentadmin/DeploymentPackage.html) is defined in [OSGi Service Platform Service Compendium](https://osgi.org/download/r4v41/r4.cmpn.pdf), paragraph "114 Deployment Admin Specification". Basically, take all those jars and put them in a big jar: this is the dp. – Alessandro Da Rugna Mar 11 '15 at 14:43
  • I'm not aware of any support for Deployment Admin in existing maven plugins, nor of any containers that use it. If you do want to package your bundles like that the `maven assembly plugin` might be an option. – Nick Wilson Mar 11 '15 at 15:56
  • Thank you for the hint, I'll dig into `maven assembly plugin` then. I can build DPs manually so I'm pretty sure what I do is right... on the other hand, this defeats the entire purpose of using Maven. – Alessandro Da Rugna Mar 11 '15 at 16:01
  • As a Tycho committer, I never heard of the requirement to build Deployment Packages. If you want to promote the requirement, you should [open an enhancement request in Tycho's issue tracker](https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Tycho) – oberlies Mar 20 '15 at 15:58

1 Answers1

2

That answer may come a bit late, but I recently created a Maven plugin "de.dentrassi.maven:osgi-dp" which can create those "DP"s.

See: https://ctron.github.io/osgi-dp/plugin-info.html

You can either create a specialized "dp" packaging or re-use Eclipse Tycho's feature metadata:

<plugin>
    <groupId>de.dentrassi.maven</groupId>
    <artifactId>osgi-dp</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>build</goal>
            </goals>
        </execution>
    </executions>
</plugin>

For a full example of using Tycho for compiling and "osgi-dp" for creating the deployment package see the integration test at GitHub.

ctron
  • 538
  • 3
  • 13