Maven 2.x WAR Plugin

WebRessource not filtered

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.1-alpha-1
  • Fix Version/s: 2.1-alpha-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    windows, maven 2.0.7
  • Number of attachments :
    1

Description

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>

Activity

Hide
Stephane Nicoll added a comment -

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.

Show
Stephane Nicoll added a comment - 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.
Hide
Jean-Yves LEBLEU added a comment -

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.

Show
Jean-Yves LEBLEU added a comment - 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.
Hide
Jean-Yves LEBLEU added a comment - - 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.

Show
Jean-Yves LEBLEU added a comment - - 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.
Hide
Stephane Nicoll added a comment -

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.

Show
Stephane Nicoll added a comment - 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.
Hide
Olivier Lamy added a comment -

Ok Stephane, we have just to find the time to chat.
I have added an it for this issue.

Show
Olivier Lamy added a comment - Ok Stephane, we have just to find the time to chat. I have added an it for this issue.
Hide
Olivier Lamy added a comment -

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 ?

Show
Olivier Lamy added a comment - 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 ?
Hide
Stephane Nicoll added a comment -

well ... No

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

Show
Stephane Nicoll added a comment - well ... No handleWebAppSourceDirectory won't filter anything. This is the default goal used to copy the content of src/main/webapp.
Hide
Olivier Lamy added a comment -

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>

Show
Olivier Lamy added a comment - 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>
Hide
Olivier Lamy added a comment -

fix in rev 600742.
Filtering targetPath which contains only . or ./ because they cause failures in the PathSet recording.

Show
Olivier Lamy added a comment - fix in rev 600742. Filtering targetPath which contains only . or ./ because they cause failures in the PathSet recording.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: