Issue Details (XML | Word | Printable)

Key: MASSEMBLY-73
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: John Casey
Reporter: vinoth rajasekaran
Votes: 1
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Maven 2.x Assembly Plugin

Sharing a default assembly descriptor across sub modules

Created: 02/Mar/06 04:44 AM   Updated: 16/Feb/09 07:12 PM
Component/s: None
Affects Version/s: 2.0.1
Fix Version/s: 2.2-beta-2

Time Tracking:
Not Specified

Issue Links:
Duplicate
 
Related
 


 Description  « Hide
I have a multi-project folders setup like one shown below,

root

_ sub-folder1
_ sub-folder2
_ sub-folder3
_ etc

Have a root pom.xml at the root folder level and in that I have defined
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/descriptor.xml
</descriptor>
</descriptors>
</configuration>
</plugin>

Above descriptor works fine only if I have defined a descriptor file on the src/main/assembly folder for each sub-folder1, sub-folder2, etc.
It would be great if maven supports me in defining a common assembly descriptor and can be shared by all the sub modules from a common location.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
John Casey added a comment - 13/Jul/07 02:49 PM
I just enabled this feature, with a slightly different solution. What you're really talking about is a standard assembly descriptor for more than one project. If your descriptor were built into the assembly plugin, it'd simply be a standard descriptorRef configuration. To enable this sort of behavior for standardized descriptors outside the assembly plugin itself, you can do the following:

Define a project that contains the standardized descriptor. Here's an example layout based on the integration test in:

http://svn.apache.org/repos/asf/maven/plugins/maven-assembly-plugin/src/it/basic-features/assemblyDescriptor-artifact

The pom.xml looks like this:

<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.test</groupId>
    <artifactId>assemblyDescriptor-artifact</artifactId>
    <version>1</version>
  </parent>
  
  <artifactId>descriptor</artifactId>
  <packaging>assembly-descriptor</packaging>
  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-artifact-types</artifactId>
        <version>2.2-beta-2-SNAPSHOT</version>
      </extension>
    </extensions>

    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-2-SNAPSHOT</version>
      </plugin>
    </plugins>
  </build>
</project>

The assembly descriptor is in src/main/resources/assembly-descriptor.xml by default, and looks like this in the example:

<assembly>
  <id>fromArtifact</id>
  <formats>
    <format>dir</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <files>
    <file>
      <source>src/config/a/file.txt</source>
      <outputDirectory>a</outputDirectory>
      <filtered>true</filtered>
    </file>
    <file>
      <source>src/config/b/file.txt</source>
      <outputDirectory>b</outputDirectory>
      <destName>file.txt</destName>
      <filtered>true</filtered>
    </file>
  </files>
</assembly>

(so, pretty much normal).

You can use the standard descriptor after installing it into the repository with a pom.xml like the following:

<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.test</groupId>
    <artifactId>assemblyDescriptor-artifact</artifactId>
    <version>1</version>
  </parent>
  
  <artifactId>assembly</artifactId>
  
  <build>
    <filters>
      <filter>a.properties</filter>
    </filters>
        
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-2-SNAPSHOT</version>
        <configuration>
          <descriptors>
            <descriptor>org.test:descriptor:1</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Note the extension in the standard descriptor's pom.xml.


Grégory Joseph added a comment - 09/Nov/07 02:30 PM
Would there be a way to filter the assembly descriptor itself, based on properties from the project/pom using it ?

Wouter Hermeling added a comment - 19/Nov/07 03:47 AM
I'm confused. Why not choose for uploading the assembly descriptor in a repository like it is done for the site.xml of the site plugin???

With this solution:

  • If i want to use the solution above, i have to change the packaging of my parent project to: assembly-descriptor
  • i cannot to reuse an assembly descriptor in another project (with a different parent pom hierarchy

NOTE: Since i require this functionality, i might implement a site-plugin like solution and post the patch here.


Grégory Joseph added a comment - 21/Nov/07 03:27 PM
John, wouldn't it be possible to bundle multiple assemblies in a single artifact ? On a related note, how can components be (re)used in the context of "artifact'ed" assemblies ?

Kaizer Sogiawala added a comment - 17/May/08 11:28 PM
What are the plans of releasing maven-assembly-artifact-types:2.2-beta-2 ?
I see maven-assembly-plugin:2.2-beta-2 is already available

Grégory Joseph added a comment - 02/Sep/08 09:27 AM - edited
I surprisingly had to add
<configuration>
          <ignoreMissingDescriptor>true</ignoreMissingDescriptor>
</configuration>
to the assembly plugin configuration when trying this again today. How come this could have changed ? (i updated my maven deps to 2.0.9 but I'm don't really see how that would have modified this behaviour)

Also, a little bump on the question above.


John Casey added a comment - 02/Sep/08 11:20 AM
There's a much simpler way to accomplish all this. In fact, I've even moved away from using the descriptor and component packaging types in favor of it. Simply put all your standardized descriptors, components, etc. into a normal jar project, and install that project. The project directory might look something like this:
/ my-custom-assemblies
|   +- pom.xml
|   +- src
|   |   +- main
|   |   |   +- resources
|   |   |   |   +- assemblies
|   |   |   |   |   +- custom-one.xml
|   |   |   |   |   +- custom-two.xml

Then, in the plugin-level dependencies of the POM from which you want to create an assembly (or, it could be in the top-level POM for a bunch of projects you want to use the same assembly...you can get pretty creative using pluginManagement here), you simply reference that standardized assembly-descriptor project:

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-2</version>
        <dependencies>
          <dependency>
            <groupId>org.myproject</groupId>
            <artifactId>my-custom-assemblies</artifactId>
            <version>1.0</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptorRefs>
                <descriptorRef>custom-one.xml</descriptorRef>
                <descriptorRef>custom-two.xml</descriptorRef>
              </descriptorRefs>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

Then, wherever you want a sub-module to create these two assemblies, you add this to the sub-module pom:

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

Grégory Joseph added a comment - 02/Sep/08 12:59 PM
ha, excellent, works indeed and is simpler. The documentation for descriptorRefs doesn't make this obvious, tho.

Thanks !