Hi, @Justin Thanks for your response. I see classifiers used quite a bit to produce artifacts other than the "standard" tests, source and javadoc - can you point me to an explanation of why this is a bad practice? (forgive me - I'm not being thorny, would just like to understand more). AFAIK BNDtools and P2 allow more than one artifact per source module, is this a legacy of maven v1,v2 to be relaxed in v3?
We currently have tons of tiny bundles - many consisting of little more than a service interface (exported) and implementation (private). To split these out so that they consist of just a single interface in one bundle and a single service in another is a source code management nightmare (while I desperately want neater wiring of bundles when it comes to deploying minor, non-API breaking changes, I'm not sure this is worth the expense of such granular maven modules). Aside from this request being against maven best practices, looking through Jira I can see a few tickets referring to classifiers and bundle plugin, e.g. FELIX-492, FELIX-1021 - so is this working fine and have I just messed up my pom? thanks, Caspar On 8 August 2011 14:54, Justin Edelson <[email protected]> wrote: > 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 <[email protected]> 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> > > >

