Maven 2.x Assembly Plugin

Clarify or fix <file> relative scoping in assembly descriptor to be module centric or location of mvn execution

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.1
  • Fix Version/s: 2.2
  • Component/s: None
  • Labels:
    None
  • Environment:
    windows xp
  • Number of attachments :
    0

Description

According to http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html, the assembly descriptor's <file> source is supposed to be absolute or relative from the module's directory. This works when I execute mvn in the module directory. But when I run it from a top level super project, it seems to run from that higher level project. This isn't how the <fileSet> works, which we were using before, but we needed to set filtering to true, which caused this to break.

So this is how we have to write this to make this work from the top level, but it breaks when running the assembly from this directory.
<files>
<file>
<source>fileutil/src/main/scripts/FileUploadUtility.bat</source>
<outputDirectory>file-utility</outputDirectory>
<filtered>true</filtered>
</file>
</files>

This is how it used to be specified, where it worked both from the top level and from the subdirectory:
<fileSets>
<fileSet>
<directory>../fileutil</directory>
<outputDirectory>file-utility</outputDirectory>
<includes>
<include>FileUploadUtility.bat</include>
</includes>
</fileSet>
</fileSets>

Hopefully this won't make a difference, but we've plugged our assembly into the execution of the package phase. This is copied from the pom.xml of the module.

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<goals>
<goal>attached</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

Activity

Hide
John Casey added a comment -

review the use of project.getBasedir() vs. just using the assumed basedir when handling fileItem sources.

Show
John Casey added a comment - review the use of project.getBasedir() vs. just using the assumed basedir when handling fileItem sources.
Hide
Andreas Johansson added a comment - - edited

I guess fixing this issue will also allow use of relative paths to filter resources when invoking maven from outside the module.

i.e.
[pom.xml]
...
<filter>src/main/resources/filterA.properties</filter>
...

[dist.xml]
<assembly>
...
<fileSets>
<fileSet>
...
<filtered>true</filtered>
</fileSet>
</fileSets>
...
</assembly>

Breaks when running from parent/top module (mvn -am -pl dist ...) - Error loading property file 'src/main/resources/filterA.properties'

[EDIT]
As John states above you can fix the issue by prefixing the paths with ${project.basedir} until it is being done automatically by the plugin.

Show
Andreas Johansson added a comment - - edited I guess fixing this issue will also allow use of relative paths to filter resources when invoking maven from outside the module. i.e. [pom.xml] ... <filter>src/main/resources/filterA.properties</filter> ... [dist.xml] <assembly> ... <fileSets> <fileSet> ... <filtered>true</filtered> </fileSet> </fileSets> ... </assembly> Breaks when running from parent/top module (mvn -am -pl dist ...) - Error loading property file 'src/main/resources/filterA.properties' [EDIT] As John states above you can fix the issue by prefixing the paths with ${project.basedir} until it is being done automatically by the plugin.

People

Vote (2)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: