Maven assembly Plugin with Maven Jar Plugin

assembliesjarmaven-2

I'm trying to use the maven assembly plugin for the first time. Essentially, I want to combine the output of the maven assembly plugin with that of the maven jar plugin into the target/classes directory so I can still run the app within Eclipse.

I couldn't find a way to tell the maven jar plugin to collect the output of the maven assembly plugin. Similarly, I found no way to tell assembly plugin to put its output into target/classes.

The closes i cam to a solution was to tell assembly plugin to output its result into classes.dir directory. The suffix 'dir' is the format used while 'classes' is the finalName define in the plugin configuration.

I was hoping that directory-single would force assembly plugin to ignore the format and hence, output in the classes directory. This doesn't work for me; am i misinterpreting the description of this goal?

How would you guys solve this issue? Below is my assembly plugin declaration in the pom as well as my descriptor:

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2-beta-1</version>
            <executions>
                <execution>
                    <id>package</id>
                    <goals>
                         <goal>directory-single</goal> 
                    </goals>
                    <phase>package</phase>
                </execution>
            </executions>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                <finalName>classes</finalName>

                <descriptors>
                    <descriptor>descriptor.xml</descriptor>
                </descriptors>
            </configuration>
        </plugin>


     <assembly>
     <files>
    <file>
        <source>${repository-path}</source>
        <outputDirectory>/</outputDirectory>
        <filtered>true</filtered>
        <destName>repository.xml</destName>
    </file>
    </files>
    <fileSets>
    <fileSet>
        <directory>src/main/resources</directory>
        <outputDirectory>/</outputDirectory>
    </fileSet>
    <fileSet>
         <directory>${project.build.directory}</directory>
    </fileSet>
   </fileSets>
  </assembly>

Best Answer

That's exactly what i am trying to do. How would you do that? That is you have two files Dev.xml and Prod.xml and you want to include them as Config.xml depending on the profile.

You could use the maven-antrun-plugin and profiles to delete/copy/rename configuration files depending on the target environment (this is one solution). Have a look at Building For Different Environments with Maven 2, this guide shows precisely how to achieve this.