Thanks a lot for your so helpful answer Barrie!

Alexis

On 8/31/06, Barrie Treloar <[EMAIL PROTECTED]> wrote:

On 8/30/06, Alexis Midon <[EMAIL PROTECTED]> wrote:
> here is what I have in my parent pom:
>
>          <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-assembly-plugin</artifactId>
>                 <configuration>
>                     <descriptors>
>                         <descriptor>src/assembly/assembly-2.1.2m.xml
> </descriptor>
>                     </descriptors>
>                 </configuration>
>             </plugin>

Examples, sure.

But before I start, Wilfred suggested using attached but this goal
will fail in an aggregated environment. You have to use single
instead.

In my parent pom I have, ROOT/pom.xml:
        <groupId>my.company</groupId>
        <artifactId>product</artifactId>
        <packaging>pom</packaging>
        <version>1.0-SNAPSHOT</version>
...
        <build>
                <pluginManagement>
                        <plugins>
                                <plugin>
                                        <groupId>org.apache.maven.plugins
</groupId>

                                        
<artifactId>maven-assembly-plugin</artifactId>
                                        <executions>
                                                <execution>

                                                        
<id>assembly:package</id>

                                                        <phase>package</phase>
                                                        <goals>
                                                                <!--
                                                                        Work
around for http://jira.codehaus.org/browse/MASSEMBLY-97
                                                                        as
the goal should be attached.
                                                                -->

                                                                
<goal>single</goal>
                                                        </goals>
                                                        <configuration>

                                                                <descriptors>

                                                                        
<descriptor>

                                                                                
src/main/assembly/bin.xml

                                                                        
</descriptor>

                                                                </descriptors>
                                                        </configuration>
                                                </execution>
                                        </executions>
                                </plugin>

This binds the maven-assembly-plugin to the package phase of the
lifecycle (
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
)
and runs the "single" goal of the plugin.

The configuration section provides the configuration details needed
for the plugin. In this case, that the descriptor file in
src/main/assembly/bin.xml should be used.  I write my own descriptor
as I have found the built in descriptors to not be complete enough for
my environment.

By using the pluginManagement section you are telling maven then
whenever someone includes the plugin in their build section that there
are some common behaviours you want to apply and this information is
inherited if this pom is used as a parent. Not all modules will want
to create an assembly so the parent pom does not define this plugin in
the build section. So unless the module explicitly lists this plugin
in the build section having this declaration in the pluginManagement
section does nothing.

Now in one of my modules pom.xml I have, ROOT/moduleA/pom.xml:
        <parent>
                <groupId>my.company</groupId>
                <artifactId>product</artifactId>
                <version>1.0-SNAPSHOT</version>
        </parent>
        <groupId>my.company</groupId>
        <artifactId>moduleA</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
...
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins
</groupId>

                                <artifactId>maven-assembly-plugin</artifactId>
                        </plugin>

Notice that I have not provided any phase binding, configuration or
anything else in this declaration.  I merely state I want to use the
plugin.  This is because this pom declares a parent and therefore will
inherit this plugin configuration from the parent.

In my ROOT/moduleA/src/main/assembly/bin.xml I have:
<assembly>
  <id>bin</id>
  <formats>
    <format>dir</format>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>true</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>src/main/config</directory>
      <outputDirectory>config/</outputDirectory>
      <includes>
        <include>*</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>target</directory>
      <outputDirectory></outputDirectory>
      <includes>
        <include>${artifactId}-${version}.jar</include>
      </includes>
    </fileSet>
  </fileSets>
  <files>
    <file>
      <source>src/site/apt/index.apt</source>
      <outputDirectory></outputDirectory>
      <destName>README.txt</destName>
    </file>
    <file>
      <source>src/main/scripts/start_debug.bat</source>
      <filtered>false</filtered>
    </file>
    <file>
      <source>src/main/scripts/start.bat</source>
      <filtered>false</filtered>
    </file>
    <file>
      <source>src/main/scripts/stop.bat</source>
      <filtered>false</filtered>
    </file>
  </files>
  <dependencySets>
    <dependencySet>
      <outputDirectory>lib/</outputDirectory>
      <outputFileNameMapping>
        ${artifactId}-${baseVersion}.${extension}</outputFileNameMapping>
      <unpack>false</unpack>
    </dependencySet>
  </dependencySets>
</assembly>

HTH

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to