Maven 2.x Assembly Plugin

filtering doesn't read filter files

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.2-beta-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    Linux icebox 2.6.17-1.2174_FC5 #1 Tue Aug 8 15:30:55 EDT 2006 i686 athlon i386 GNU/Linux
  • Number of attachments :
    3

Description

The assembly plugin's filtering supports POM properties like ${project.artifactId}, but not properties read from the filter file, contrary to the documentation here:

http://maven.apache.org/plugins/maven-assembly-plugin/examples/single/filtering-some-distribution-files.html

I've attached a sample app demonstrating the problem. You can run it by saying "mvn clean package." It tries to filter a README file with both ${project.artifactId} and ${homer}. ${homer} is defined in filter.properties like this:

homer=woohoo

But when you run the plugin, only ${project.artifactId} is filtered.

Issue Links

Activity

Hide
John Franey added a comment -

The documentation is wrong for versions 2.1 and 2.2-SNAPSHOT. The filters element is really a child of <build> element not the plugin's <configuration>. To be attached is a patch to the documentation.

I got this to work with maven 2.0.4 and versions 2.1 and 2.2-SNAPSHOT of the assembly plugin.

I was unable to use your pom with version 2.0 of the assembly plugin because the goal 'attached' does not apparently exist in that version of the plugin. I guess when you selected 'version' for this issue report, you didn't mean to select 2.0.

Show
John Franey added a comment - The documentation is wrong for versions 2.1 and 2.2-SNAPSHOT. The filters element is really a child of <build> element not the plugin's <configuration>. To be attached is a patch to the documentation. I got this to work with maven 2.0.4 and versions 2.1 and 2.2-SNAPSHOT of the assembly plugin. I was unable to use your pom with version 2.0 of the assembly plugin because the goal 'attached' does not apparently exist in that version of the plugin. I guess when you selected 'version' for this issue report, you didn't mean to select 2.0.
Hide
John Franey added a comment -

Correcting the example to show the filter is a child of build element, not a child of the assembly plugin's configuration element.

Show
John Franey added a comment - Correcting the example to show the filter is a child of build element, not a child of the assembly plugin's configuration element.
Hide
Paul Jungwirth added a comment -

You're right, moving the <filters> block fixed the problem. Thanks!

Sorry I marked this 2.0. I was thinking Maven version (2.0.4), not plugin version.

Show
Paul Jungwirth added a comment - You're right, moving the <filters> block fixed the problem. Thanks! Sorry I marked this 2.0. I was thinking Maven version (2.0.4), not plugin version.
Hide
Bertrand Fovez added a comment -

Hello,

The fix works fine, indeed, for the <file> tag. I tried with the <fileset> tag and it doesn't seem to work in this case.
I tested with Maven 2.0.6 and Assembly plug-in 2.2-beta-1.

I attached an sample derived from John's one.

Show
Bertrand Fovez added a comment - Hello, The fix works fine, indeed, for the <file> tag. I tried with the <fileset> tag and it doesn't seem to work in this case. I tested with Maven 2.0.6 and Assembly plug-in 2.2-beta-1. I attached an sample derived from John's one.
Hide
Bertrand Fovez added a comment -

Here is a sample derived from John's one showing that filtering doesn't seem to worok with <fileset> tag, even with the doc fix.

Show
Bertrand Fovez added a comment - Here is a sample derived from John's one showing that filtering doesn't seem to worok with <fileset> tag, even with the doc fix.
Hide
Christophe Domas added a comment -

The assembly descriptor documentation (http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html) says that it's possible to filter fileSets:

<fileSets>
<fileSet>
<directory/>
<lineEnding/>
<filtered/>
<useStrictFiltering/>
<useDefaultExcludes/>
<outputDirectory/>
<includes/>
<excludes/>
<fileMode/>
<directoryMode/>
</fileSet>
</fileSets>
<files>
<file>
<source/>
<outputDirectory/>
<destName/>
<fileMode/>
<lineEnding/>
<filtered/>
</file>
</files>

but it doesn't work with version 2.2-beta1. Could you fix it? I would prefer that you fix the code more than the doc

Show
Christophe Domas added a comment - The assembly descriptor documentation (http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html) says that it's possible to filter fileSets: <fileSets> <fileSet> <directory/> <lineEnding/> <filtered/> <useStrictFiltering/> <useDefaultExcludes/> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> </fileSet> </fileSets> <files> <file> <source/> <outputDirectory/> <destName/> <fileMode/> <lineEnding/> <filtered/> </file> </files> but it doesn't work with version 2.2-beta1. Could you fix it? I would prefer that you fix the code more than the doc
Hide
Fabrice Bellingard added a comment -

MASSEMBLY-154 added the possibility to filter fileSets.

I tested your example, and with the following assembly descriptor, the filtering works fine:

<assembly>
	<id>bin</id>
	<formats>
		<format>zip</format>
	</formats>
	<fileSets>
		<fileSet>
			<directory>target</directory>
			<outputDirectory></outputDirectory>
			<includes>
				<include>*.jar</include>
			</includes>
		</fileSet>
		<fileSet>
			<directory>${basedir}</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>README</include>
			</includes>
			<filtered>true</filtered>
		</fileSet>
	</fileSets>
</assembly>

Please note that I had to specify "${basedir}" for the <directory> of the 2nd fileSet to make it work. In your first assembly descriptor, a "/" was used instead, which prevented the README file from being filtered.

Show
Fabrice Bellingard added a comment - MASSEMBLY-154 added the possibility to filter fileSets. I tested your example, and with the following assembly descriptor, the filtering works fine:
<assembly>
	<id>bin</id>
	<formats>
		<format>zip</format>
	</formats>
	<fileSets>
		<fileSet>
			<directory>target</directory>
			<outputDirectory></outputDirectory>
			<includes>
				<include>*.jar</include>
			</includes>
		</fileSet>
		<fileSet>
			<directory>${basedir}</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>README</include>
			</includes>
			<filtered>true</filtered>
		</fileSet>
	</fileSets>
</assembly>
Please note that I had to specify "${basedir}" for the <directory> of the 2nd fileSet to make it work. In your first assembly descriptor, a "/" was used instead, which prevented the README file from being filtered.
Hide
Fabrice Bellingard added a comment -

FilSets filtering added (see MASSEMBLY-154)

Show
Fabrice Bellingard added a comment - FilSets filtering added (see MASSEMBLY-154)
Hide
Bertrand Fovez added a comment - - edited

Hello,

However, the following, based upon the previous, doesn't work :

 
<assembly>
	<id>bin</id>
	<formats>
		<format>zip</format>
	</formats>
	<fileSets>
		<fileSet>
			<directory>${basedir}/../poms/assembly/boot</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>README</include>
			</includes>
			<filtered>true</filtered>
		</fileSet>
	</fileSets>
</assembly>
Show
Bertrand Fovez added a comment - - edited Hello, However, the following, based upon the previous, doesn't work :
 
<assembly>
	<id>bin</id>
	<formats>
		<format>zip</format>
	</formats>
	<fileSets>
		<fileSet>
			<directory>${basedir}/../poms/assembly/boot</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>README</include>
			</includes>
			<filtered>true</filtered>
		</fileSet>
	</fileSets>
</assembly>
Hide
Mark Diggory added a comment - - edited

It appears that moduleSets cannot be filtered either.

<moduleSet>
         <includes>
            <include>*:war</include>
         </includes>
         <binaries>
            <includeDependencies>false</includeDependencies>
            <outputDirectory>webapps/${artifactId}</outputDirectory>
            <unpack>true</unpack>
        	<unpackOptions>
          		<filtered>true</filtered>
        	</unpackOptions>
         </binaries>
      </moduleSet>

fails on Maven 2.0.7 and Assembly-plugin 2.2-beta-2-SNAPSHOT. I have a web.xml with a ${property} that will not get filtered when I have evidence all other <files> are filtered appropriately.

Show
Mark Diggory added a comment - - edited It appears that moduleSets cannot be filtered either.
<moduleSet>
         <includes>
            <include>*:war</include>
         </includes>
         <binaries>
            <includeDependencies>false</includeDependencies>
            <outputDirectory>webapps/${artifactId}</outputDirectory>
            <unpack>true</unpack>
        	<unpackOptions>
          		<filtered>true</filtered>
        	</unpackOptions>
         </binaries>
      </moduleSet>
fails on Maven 2.0.7 and Assembly-plugin 2.2-beta-2-SNAPSHOT. I have a web.xml with a ${property} that will not get filtered when I have evidence all other <files> are filtered appropriately.

People

Vote (3)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: