I didn't see the "right" answer go by for this (or what I thought was right),
so I hope I'm not repeating something.
In one of my projects that needs a secondary jar with a subset of classes, I've
done the following:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<jar basedir="${project.build.outputDirectory}"
destfile="${project.build.directory}/${project.name}-${project.version}-client.jar"
>
<include
name="org/example/client/**/*.class" />
</jar>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.name}-${project.version}-client.jar</file>
<type>jar</type>
<classifier>client</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I've created the secondary jar with a small Ant script bound to the package
phase, but obviously there are a number of other ways you could do it. Then you
just use the build-helper plugin to attach your jar as another artifact with a
classifier to distinguish it from the primary artifact. You'll also need that
classifier when referring to the secondary artifact as a dependency.
Chris Hilton
> -----Original Message-----
> From: sol myr [mailto:[EMAIL PROTECTED]
> Sent: Friday, 26 May, 2006 17:50
> To: [email protected]
> Subject: [maven2] Generating several artifacts per project ?
>
> Hi,
>
> Newbie question:
> Is it possible to generate several artifacts (jars) from
> the same project ?
> I have a single project (single POM, with no sub-projects).
> I'd like to make it so that when I call 'mvn package', it
> will create 3 different jars (say, "client.jar",
> "server.jar", and "util.jar"), and place them all under 'target'.
>
> I *know* this goes agains the recommendations & phylosophy
> of Maven2...
> But we really must limit ourselves to a single POM, due to
> limitations of my company's IDE and version control.
>
> Thanks.
>
>
> ---------------------------------
> Blab-away for as little as 1ยข/min. Make PC-to-Phone Calls
> using Yahoo! Messenger with Voice.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]