dev@glassfish.java.net

OSGi bundle / hk2 inhabitant help needed...

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Tue, 23 Sep 2008 20:30:11 -0700


I have a pom.xml file where I want to package one of the dependencies inline, and include some additional files which happen to implment an HK2 @Service.  I have this almost working.  The build works correctly, and everything appears in the jar and manifest file correctly... except the META-INF/inhabitants/default file that was generated (and appears correctly in target/classes/META-INF/inhabitants/default).  I have wasted a couple hours playing guess-and-check to find the magic combination or some work-a-round.  However, I the ease-of-use of maven has stumped me again....

How do I do fix my pom.xml to include this file?  Note: if I remove the "executions" section, I get the "inhabitants" file, however, I don't get the embedded dependency in the jar file (or any of the related MANIFEST.MF import/export entries).  Below is the pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <parent>
        <groupId>org.glassfish.admingui</groupId>
        <artifactId>admingui</artifactId>
        <version>10.0-SNAPSHOT</version>
    </parent>
    <artifactId>console-theme-plugin</artifactId>
    <packaging>hk2-jar</packaging>
    <name>Admin Console Custom Plugin</name>
    <description>Custom Theme Plugin for Glassfish V3 Admin Console</description>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <supportedProjectTypes>
                        <supportedProjectType>hk2-jar</supportedProjectType>
                        <supportedProjectType>jar</supportedProjectType>
                        <supportedProjectType>bundle</supportedProjectType>
                    </supportedProjectTypes>
                    <instructions>
                        <Embed-Dependency>*;artifactId=webui-jsf-suntheme;inline=true</Embed-Dependency>
                        <Export-Package>org.glassfish.admingui.customtheme.*</Export-Package>
                        <_exportcontents>*</_exportcontents>

                        <X-SJWUIC-SWAED-Version>4.0</X-SJWUIC-SWAED-Version>
                        <X-SJWUIC-Theme-Version>4.3</X-SJWUIC-Theme-Version>
                        <X-SJWUIC-Theme-Timestamp>200807161313</X-SJWUIC-Theme-Timestamp>
                        <X-SJWUIC-Theme-Name>suntheme</X-SJWUIC-Theme-Name>
                        <X-SJWUIC-Theme-Prefix>/theme</X-SJWUIC-Theme-Prefix>
                        <X-SJWUIC-Theme-Messages>woodstock4_3.suntheme.messages.messages</X-SJWUIC-Theme-Messages>
                        <X-SJWUIC-Theme-Images>woodstock4_3.suntheme.properties.images</X-SJWUIC-Theme-Images>
                        <X-SJWUIC-Theme-JavaScript>woodstock4_3.suntheme.properties.javascript</X-SJWUIC-Theme-JavaScript>
                        <X-SJWUIC-Theme-ClassMapper>woodstock4_3.suntheme.properties.styles</X-SJWUIC-Theme-ClassMapper>
                        <X-SJWUIC-Theme-Stylesheets>woodstock4_3.suntheme.properties.stylesheets</X-SJWUIC-Theme-Stylesheets>
                        <X-SJWUIC-Theme-Templates>woodstock4_3.suntheme.properties.templates</X-SJWUIC-Theme-Templates>
                    </instructions>
                </configuration>
                <executions>
                    <execution>
                        <id>osgi-bundle</id>
                        <phase>package</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>

                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.common</groupId>
            <artifactId>glassfish-api</artifactId>
            <version>${glassfish-api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.admingui</groupId>
            <artifactId>console-plugin-service</artifactId>
            <version>${glassfish.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.woodstock</groupId>
            <artifactId>webui-jsf-suntheme</artifactId>
            <version>4.3.0.7</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>


Thanks in advance!

Ken