Issue Details (XML | Word | Printable)

Key: MWAR-129
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Olivier Lamy
Reporter: Jean-Yves LEBLEU
Votes: 0
Watchers: 1
Operations

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

WebRessource not filtered

Created: 06/Nov/07 09:21 AM   Updated: 03/Dec/07 06:32 PM
Component/s: None
Affects Version/s: 2.1-alpha-1
Fix Version/s: 2.1-alpha-2

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive mwar_129.zip (3 kB)

Environment: windows, maven 2.0.7


 Description  « Hide
Previously Webressources were correctly filtered and are not filtered any more

See above extract from pom.xml
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<targetPath>.</targetPath>
<includes>
<include>param.jsp</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Stephane Nicoll added a comment - 08/Nov/07 04:07 AM
whaouh, that helps!

Your extract use 2.0.2 which is obviously wrong for what you are reporting. There are also chances that the type of resources your are filtering are linked to the issue.

I guess you want the issue resolved. If it's the case, provide a sample project to reproduce your issue, that's the strict minimum.


Jean-Yves LEBLEU added a comment - 08/Nov/07 07:19 AM
You are right and sorry for this quick description,

I was a bit under rush, so I just wanted to warn about this issue, I will prepare a more descriptive text and a sample project.
I use 2.0.2 as the filtering of webressouces is not working anymore with alpha version.


Jean-Yves LEBLEU added a comment - 13/Nov/07 07:12 AM - edited
Sample project mwar_129 attached,

The file param.jsp contains properties which are set in the pom.xml.
when you run mvn clean package, these properties are replaced by the one defined in the corresponding profile.

Exemple :

mvn clean package -Dprofile1=1

param.jsp :

<c:set var="app_version" value="1.0-SNAPSHOT"/>
<c:set var="app_mainStyleSheet" value="profile1.css"/>

mvn clean package -Dprofile2=1

param.jsp :

<c:set var="app_version" value="1.0-SNAPSHOT"/>
<c:set var="app_mainStyleSheet" value="profile2.css"/>

This was working well with war plugin version 2.0.2 and not with the alpha version.


Stephane Nicoll added a comment - 24/Nov/07 02:37 AM
Olivier, this is due to the overlay overwriting strategy. Since this file is part of the webapp, it is copied by the ProjectPackagingTask (something like that)

If the target file alredy exists, it is not overwriten (first win strategy).

However, we should copy the resources first (so that we can apply filtering). Unfortunately there is this stupid "do not copy if it is the webapp source" flag used for the war:inplace goal (this sounds very hackish to me btw)

Thanks for taking care of this ; it would be good if we could chat a bit to see how we're gonna solve this.


Olivier Lamy added a comment - 24/Nov/07 05:51 AM
Ok Stephane, we have just to find the time to chat.
I have added an it for this issue.

Olivier Lamy added a comment - 26/Nov/07 04:38 PM
Stephane,
We proceed webResources before webappSourceDirectory.
WarProjectPackagingTask#performPackaging
        ...
        metainfDir.mkdirs();
        handleWebResources( context );        
        handeWebAppSourceDirectory( context );
        handleDeploymentDescriptors( context, webinfDir, metainfDir );
        ....

The easy fix is to change handeWebAppSourceDirectory before handleWebResources.
IMHO it makes senses.
WDYT ?


Stephane Nicoll added a comment - 26/Nov/07 05:59 PM
well ... No

handleWebAppSourceDirectory won't filter anything. This is the default goal used to copy the content of src/main/webapp.


Olivier Lamy added a comment - 03/Dec/07 05:55 PM
A simple workaround for your attached it is to have :

<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<targetPath></targetPath>
<includes>
<include>param.jsp</include>
</includes>
</resource>
</webResources>

Note the empty <targetPath></targetPath> instead of <targetPath>.</targetPath>


Olivier Lamy added a comment - 03/Dec/07 06:32 PM
fix in rev 600742.
Filtering targetPath which contains only . or ./ because they cause failures in the PathSet recording.