Maven 2.x Assembly Plugin

Unable to filter files while creating assembly

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

It doesn't seem to be possible to use filtering when creating assemblies. I have a couple of plain-text files which need to be updated when creating the assembly (e.g. README.TXT, .version).

Issue Links

Activity

Hide
Mike Perham added a comment -

Chris, I haven't used the assembly plugin before so forgive me if this is a a dumb question but is there any reason why you can't use standard resource filtering?

http://maven.apache.org/maven-model/maven.html#class_resource

Show
Mike Perham added a comment - Chris, I haven't used the assembly plugin before so forgive me if this is a a dumb question but is there any reason why you can't use standard resource filtering? http://maven.apache.org/maven-model/maven.html#class_resource
Hide
Chris Hagmann added a comment -

That's what I asked myself and then I tried it out ... didn't work out without hacking that plugin. Please see MRESOURCES-8.

Some people think it shouldn't be part of the maven-resource-filtering, some people think. I think it should be doable with either plugin

By the way, I'm not talking about Java resources here, but rather other files (e.g. README.TXT, release notes, etc.) which can go into a distribution archive. The copying and filtering in this case is part of the phase "package" and the "resources" can come from various source directories.

Chris

Show
Chris Hagmann added a comment - That's what I asked myself and then I tried it out ... didn't work out without hacking that plugin. Please see MRESOURCES-8. Some people think it shouldn't be part of the maven-resource-filtering, some people think. I think it should be doable with either plugin By the way, I'm not talking about Java resources here, but rather other files (e.g. README.TXT, release notes, etc.) which can go into a distribution archive. The copying and filtering in this case is part of the phase "package" and the "resources" can come from various source directories. Chris
Hide
Dan Tran added a comment -

not sure why this is not working, could you send in a sample descriptor file?

Show
Dan Tran added a comment - not sure why this is not working, could you send in a sample descriptor file?
Hide
Chris Hagmann added a comment -

Surely I can, but I have nothing in my descriptor regarding filtering. I don't see any docs describing anything about filtering, and the descriptor doesn't really tell me anything either. Can you indicate to me what to do in the descriptor regarding filtering?

Show
Chris Hagmann added a comment - Surely I can, but I have nothing in my descriptor regarding filtering. I don't see any docs describing anything about filtering, and the descriptor doesn't really tell me anything either. Can you indicate to me what to do in the descriptor regarding filtering?
Hide
Corridor Software Developer added a comment -

agreed, this is an issue when creating distributions for various environments. We're currently working around it by having multiple file sets with the tweaks already in them and a profile per environment to specify which set to grab. Since only 2-4 lines in the files change, this is obviously inefficient, especially when the files need a sweeping change.

Show
Corridor Software Developer added a comment - agreed, this is an issue when creating distributions for various environments. We're currently working around it by having multiple file sets with the tweaks already in them and a profile per environment to specify which set to grab. Since only 2-4 lines in the files change, this is obviously inefficient, especially when the files need a sweeping change.
Hide
Allan Ramirez added a comment -

just tested the resource filtering and it is working fine with me. can you attach your use case?

Show
Allan Ramirez added a comment - just tested the resource filtering and it is working fine with me. can you attach your use case?
Hide
Allan Ramirez added a comment -

ok.. finally reproduce it, files placed in src/main/resources does get filtered in the bundled jar but outside of it doesnt

Show
Allan Ramirez added a comment - ok.. finally reproduce it, files placed in src/main/resources does get filtered in the bundled jar but outside of it doesnt
Hide
Allan Ramirez added a comment -

added new tag ("<filtered>") in assembly descriptor for FileItem which will filter
the file and add the filtered file to the assembly.

<files>
<file>
<source>README.TXT</source>
<filtered>true</filtered>
</file>
</files>

Show
Allan Ramirez added a comment - added new tag ("<filtered>") in assembly descriptor for FileItem which will filter the file and add the filtered file to the assembly. <files> <file> <source>README.TXT</source> <filtered>true</filtered> </file> </files>
Hide
Corridor Software Developer added a comment -

Fabulous. Thanks for the clarification.

Show
Corridor Software Developer added a comment - Fabulous. Thanks for the clarification.
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
Arnaud Heritier added a comment -

See Christophe Domas comment

Show
Arnaud Heritier added a comment - See Christophe Domas comment
Hide
Brett Porter added a comment -

Arnaud - did it work in 2.1? We should create a new issue rather than reopening something in an already released version.

Show
Brett Porter added a comment - Arnaud - did it work in 2.1? We should create a new issue rather than reopening something in an already released version.
Hide
Brett Porter added a comment -

re-closing for the original fix. See MASSEMBLY-154 for the addition to filterSet (patch included).

Show
Brett Porter added a comment - re-closing for the original fix. See MASSEMBLY-154 for the addition to filterSet (patch included).

People

Vote (2)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
6h
Original Estimate - 6 hours Original Estimate - 6 hours
Remaining:
0m
Remaining Estimate - 0 minutes
Logged:
12h
Time Spent - 12 hours