Issue Details (XML | Word | Printable)

Key: MASSEMBLY-178
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Paul Jungwirth
Votes: 3
Watchers: 3
Operations

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

filtering doesn't read filter files

Created: 22/Jan/07 09:37 AM   Updated: 01/Feb/08 10:37 AM   Resolved: 05/Jul/07 08:09 AM
Return to search
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.2-beta-2

Time Tracking:
Not Specified

File Attachments: 1. File filt-dist.diff (0.8 kB)
2. GZip Archive filter-test.tar.gz (1 kB)
3. Zip Archive filter-test.zip (3 kB)

Environment:
Linux icebox 2.6.17-1.2174_FC5 #1 Tue Aug 8 15:30:55 EDT 2006 i686 athlon i386 GNU/Linux
Issue Links:
Related


 Description  « Hide

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.



John Franey added a comment - 20/Feb/07 11:24 AM

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.


John Franey added a comment - 20/Feb/07 11:25 AM

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


Paul Jungwirth added a comment - 20/Feb/07 11:42 AM

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.


Bertrand Fovez added a comment - 22/Apr/07 04:41 PM

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.


Bertrand Fovez added a comment - 22/Apr/07 04:43 PM

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.


Christophe Domas added a comment - 10/May/07 09:48 AM

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


Fabrice BELLINGARD added a comment - 05/Jul/07 08:05 AM

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.


Fabrice BELLINGARD added a comment - 05/Jul/07 08:09 AM

FilSets filtering added (see MASSEMBLY-154)


Bertrand Fovez added a comment - 06/Jul/07 04:00 AM - 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>

Mark Diggory added a comment - 07/Jul/07 04:37 PM - 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.