This is not a good idea as it runs against Maven best practices. You
should restructure your project to produce a single artifact per
project.

Justin

On Mon, Aug 8, 2011 at 6:23 AM, Caspar MacRae <ear...@gmail.com> wrote:
> Hello,
>
> I'm trying to get a single maven module to build separate bundles by
> classifier - the intention is to be able to have multiple build artifacts
> per project;
>
>
>   1. no classifier with included API packages exported and imported, with
>   included implementation packages private
>   2. "-api" classifier with only API packages (and these exported) without
>   implementation
>   3. "-imp" classifier with the API packages imported but not included, and
>   implementation packages private
>
> I can build the Jars with the correct packages included/excluded, but it's
> the same META-INF/MANIFEST.MF used for all three and DS the
> OSGI-INF/serviceComponents.xml is generated but not included.
>
> Hoping what I'm attempting is actually possible and that it's just something
> stupid I'm doing wrt the lifecycle phase.
>
> Is there anybody out there that can see what I'm missing/doing wrong?
>
>
> thanks,
>
> Caspar
>
>
> Here's the pluginManagement pom snippet:
>
>
>        </pluginManagement>
>
>             </plugins>
>
> <!-- ... --->
>
>                <plugin>
>                    <groupId>org.apache.maven.plugins</groupId>
>                    <artifactId>maven-jar-plugin</artifactId>
>                    <version>2.3.1</version>
>                    <configuration>
>                        <archive>
>
> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
>                        </archive>
>                    </configuration>
>                    <executions>
>                        <execution>
>                            <id>jar-api</id>
>                            <goals>
>                                <goal>jar</goal>
>                            </goals>
>                            <configuration>
>                                <classifier>api</classifier>
>                                <includes>
>                                    <includes>**/api/*</includes>
>                                </includes>
>                            </configuration>
>                        </execution>
>                        <execution>
>                            <id>jar-imp</id>
>                            <goals>
>                                <goal>jar</goal>
>                            </goals>
>                            <configuration>
>                                <classifier>imp</classifier>
>                                <includes>
>                                    <includes>**/imp/*</includes>
>                                </includes>
>                            </configuration>
>                        </execution>
>                    </executions>
>                </plugin>
>
>                <plugin>
>                    <!-- Process the DS annotations -->
>                    <groupId>org.apache.felix</groupId>
>                    <artifactId>maven-scr-plugin</artifactId>
>                    <version>1.7.0</version>
>                    <executions>
>                        <execution>
>                            <id>scr-imp</id>
>                            <goals>
>                                <goal>scr</goal>
>                            </goals>
>                            <configuration>
>                                <classifier>imp</classifier>
>                                <generateAccessors>true</generateAccessors>
>                            </configuration>
>                        </execution>
>                    </executions>
>                </plugin>
>
>                <plugin>
>                    <!-- Generate OSGi bundle MAINFEST.MF entries -->
>                    <groupId>org.apache.felix</groupId>
>                    <artifactId>maven-bundle-plugin</artifactId>
>                    <version>2.3.5</version>
>                    <extensions>true</extensions>
>                    <configuration>
>                        <archive>
>                            <addMavenDescriptor>true</addMavenDescriptor>
>                        </archive>
>                        <supportedProjectTypes>
>                            <supportedProjectType>jar</supportedProjectType>
>                            <supportedProjectType>war</supportedProjectType>
>                        </supportedProjectTypes>
>                        <instructions>
>                            <Bundle-Vendor>${project.organization.name
> }</Bundle-Vendor>
>
> <Bundle-ContactAddress>${project.organization.url}</Bundle-ContactAddress>
>
> <Bundle-Description>${project.description}</Bundle-Description>
>                            <Bundle-DocURL>${bundle.doc.url}</Bundle-DocURL>
>
> <Bundle-Category>${bundle.category}</Bundle-Category>
>
>                            <!-- PAX mangles this, it uses the name of the
> project for the symbolicname
>                                of test bundle? <Bundle-SymbolicName>${
> project.name}</Bundle-SymbolicName> -->
>
> <Bundle-SymbolicName>${bundle.symbolicname}</Bundle-SymbolicName>
>
>
> <Bundle-Version>${project.version}</Bundle-Version>
>                            <_include>-osgi.bnd</_include>
>                            <Import-Package>*</Import-Package>
>                            <Export-Package>
>
> !${project.artifactId}.imp.*,${project.artifactId}.*
>                            </Export-Package>
>
> <Private-Package>${project.artifactId}.imp.*</Private-Package>
>                        </instructions>
>                    </configuration>
>                    <executions>
>                        <execution>
>                            <id>bundle-api</id>
>                            <goals>
>                                <goal>manifest</goal>
>                            </goals>
>                            <phase>process-classes</phase>
>                            <inherited>true</inherited>
>                            <configuration>
>                                <classifier>api</classifier>
>                                <instructions>
>
> <Export-Package>${project.artifactId}.*</Export-Package>
>                                    <Private-Package>!*</Private-Package>
>                                </instructions>
>                            </configuration>
>                        </execution>
>                        <execution>
>                            <id>bundle-imp</id>
>                            <goals>
>                                <goal>manifest</goal>
>                            </goals>
>                            <phase>process-classes</phase>
>                            <inherited>true</inherited>
>                            <configuration>
>                                <classifier>imp</classifier>
>                                <instructions>
>
> <Export-Package>!${project.artifactId}.imp.*,${project.artifactId}.*</Export-Package>
>
> <Private-Package>${project.artifactId}.imp.*</Private-Package>
>                                </instructions>
>                            </configuration>
>                        </execution>
>
>                    </executions>
>                </plugin>
> <!-- ... --->
>            </plugins>
>        </pluginManagement>
>
>
> And usage in a child POM looks like:
>
>
>    <build>
>        <plugins>
> <!-- ... --->
>
>            <plugin>
>                <groupId>org.apache.felix</groupId>
>                <artifactId>maven-bundle-plugin</artifactId>
>            </plugin>
>            <plugin>
>                <groupId>org.apache.felix</groupId>
>                <artifactId>maven-scr-plugin</artifactId>
>            </plugin>
>            <plugin>
>                <groupId>org.apache.maven.plugins</groupId>
>                <artifactId>maven-jar-plugin</artifactId>
>            </plugin>
> <!-- ... --->
>
>        </plugins>
>    </build>
>

Reply via email to