dev@glassfish.java.net

Re: [Ask/Help]About glassfish-jar packaging

From: Romain Grecourt <romain.grecourt_at_oracle.com>
Date: Thu, 25 Apr 2013 10:56:25 +0200

glassfish-jar is a custom maven packaging which defines the following
lifecycle:

<generate-sources>org.glassfish.hk2:config-generator:generate-injectors</generate-sources>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
<process-classes>
org.glassfish.hk2:osgiversion-maven-plugin:compute-osgi-version,
org.glassfish.hk2:hk2-inhabitant-generator:generate-inhabitants,
org.apache.felix:maven-bundle-plugin:manifest,
org.glassfish.build:command-security-maven-plugin:check
</process-classes>
<generate-test-sources>org.glassfish.hk2:config-generator:generate-test-injectors</generate-test-sources>
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<process-test-classes>org.glassfish.hk2:hk2-inhabitant-generator:generate-test-inhabitants</process-test-classes>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>

It does trigger the execution of bundle:manifest, not bundle:bundle.
Hence, it does not repackage class files but just generates the OSGi
metadata.

If you want to repackage some classes you'll have to fit another plugin
execution in your pom.xml.

Among many ways to do that, my vote goes to
glassfishbuild-maven-plugin:unpack-sources.
This assumes that the corresponding sources.jar is available, it will
unpack it and attached the unpacked sources to the maven-project to make
them visible to all other plugins (e.g. maven-compiler and so on).
The main advantage of this solution is that you recompile the sources
and you are able to generate proper sources and javadoc jars.

Thanks,
Romain

On 4/25/13 10:34 AM, Tang Yong wrote:
> Hi Romain,
> CC: Sahoo,
>
> I have a question about glassfish-jar packaging, The attachment is my
> pom and osgi.bundle files.
>
> [Question]
> I wish wrapping org.apache.felix.bundlerepository related class file
> into my bundle jar.
>
> If I make packaging is bundle liking the following,
>
> <artifactId>glassfish-obr-builder</artifactId>
> <version>4.0-SNAPSHOT</version>
> <name>Builds OBR from a set of OSGi bundles</name>
> <packaging>bundle</packaging>
>
> Then, wrapping is successful.
>
> However, once I make packaging is glassfish-jar, wrapping will failed
> and org.apache.felix.bundlerepository related class file will be not
> wrapped into my bundle jar.
>
> Whether for glassfish-jar, the feature is not supported? Or is there
> something wrong with me?
>
> Thanks
> --Tang