You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David Birch <da...@gmail.com> on 2007/06/11 17:49:32 UTC

filtering resources in maven-war-plugin

Hi,
   i seem to be getting some strange behaviour with the war plugin (versions
2.0.2 & 2.0.3-SNAPSHOT), if i do a build with the goal "install", the
resources are filtered properly, if i only go so far as war:exploded or
war:war, they don't get filtered. I have debugged, and it looks like there
are 3 steps of calling the plugin in a normal install (trace is below),
during the first call on the plugin code,  the resources are copied but not
filtered (webResources property is null), but on the subsequent invokes the
resources are filted. When i execute standalone calls to war:exploded or
war:war, the resources are not filtered - webResources is null & thus the
filtering code is never invoked.
FYI - i have tested with both maven 2.0.4 & 2.0.6

If anyone has any ideas so i can avoid the full install process would be
great - the wars i have inherited are a little on the large side so all the
construction & copying is a bit of a slowdown.

thanks
David

the build section of my pom is like so:
<build>

        <filters>
            <filter>build.properties</filter>
        </filters>

        <resources>
            <!-- filter the xml & properties resources -->
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                    <include>**/*.vm</include>
                    <include>**/*.txt</include>
                </includes>
            </resource>
        </resources>

        <plugins>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <!-- goal>compile</goal>
                        <goal>install</goal -->
                        <goal>war</goal>
                        <goal>exploded</goal>
                        <goal>inplace</goal>
                    </goals>
                    <configuration>

<warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <webResources>
                            <resource>
                                <directory>src/main/webapp</directory>
                                <filtering>true</filtering>
                                <includes>
                                    <include>**/*.jsp</include>
                                    <include>**/*.xml</include>
                                    <include>**/*.properties</include>
                                </includes>
                            </resource>
                        </webResources>
                     </configuration>
                </execution>
            </executions>
       </plugin>
        </plugins>

    </build>

the trace of a std build using the install goal is:

[INFO] [war:war]
[INFO] Exploding webapp...
[INFO] Assembling webapp WARTest in
C:\Java\workspace\TestWARPlugin\target\WARTe
st-1.0
[INFO] Copy webapp webResources to
C:\Java\workspace\TestWARPlugin\target\WARTes
t-1.0
[INFO] Generating war C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
[INFO] Building war: C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
[INFO] [war:war {execution: default}]
[INFO] Exploding webapp...
[INFO] Assembling webapp WARTest in
C:\Java\workspace\TestWARPlugin\target\WARTe
st-1.0
[INFO] Copy webapp webResources to
C:\Java\workspace\TestWARPlugin\target\WARTes
t-1.0
[INFO] Copy webapp webResources to
C:\Java\workspace\TestWARPlugin\target\WARTes
t-1.0
[INFO] Generating war C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
[INFO] Building war: C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
[INFO] [war:exploded {execution: default}]
WarExplodedMojo by DB
[INFO] Exploding webapp...
[INFO] Assembling webapp WARTest in
C:\Java\workspace\TestWARPlugin\target\WARTe
st-1.0
[INFO] Copy webapp webResources to
C:\Java\workspace\TestWARPlugin\target\WARTes
t-1.0
[INFO] Copy webapp webResources to
C:\Java\workspace\TestWARPlugin\target\WARTes
t-1.0
[INFO] [install:install]

Re: filtering resources in maven-war-plugin

Posted by capira <ca...@gmail.com>.
I have same problem here.

Any ideas?

Regards,

Raul Casado


David Birch wrote:
> 
> Hi,
>    i seem to be getting some strange behaviour with the war plugin
> (versions
> 2.0.2 & 2.0.3-SNAPSHOT), if i do a build with the goal "install", the
> resources are filtered properly, if i only go so far as war:exploded or
> war:war, they don't get filtered. I have debugged, and it looks like there
> are 3 steps of calling the plugin in a normal install (trace is below),
> during the first call on the plugin code,  the resources are copied but
> not
> filtered (webResources property is null), but on the subsequent invokes
> the
> resources are filted. When i execute standalone calls to war:exploded or
> war:war, the resources are not filtered - webResources is null & thus the
> filtering code is never invoked.
> FYI - i have tested with both maven 2.0.4 & 2.0.6
> 
> If anyone has any ideas so i can avoid the full install process would be
> great - the wars i have inherited are a little on the large side so all
> the
> construction & copying is a bit of a slowdown.
> 
> thanks
> David
> 
> the build section of my pom is like so:
> <build>
> 
>         <filters>
>             <filter>build.properties</filter>
>         </filters>
> 
>         <resources>
>             <!-- filter the xml & properties resources -->
>             <resource>
>                 <filtering>true</filtering>
>                 <directory>src/main/resources</directory>
>                 <includes>
>                     <include>**/*.xml</include>
>                     <include>**/*.properties</include>
>                     <include>**/*.vm</include>
>                     <include>**/*.txt</include>
>                 </includes>
>             </resource>
>         </resources>
> 
>         <plugins>
>             <plugin>
>             <groupId>org.apache.maven.plugins</groupId>
>             <artifactId>maven-war-plugin</artifactId>
>             <executions>
>                 <execution>
>                     <goals>
>                         <!-- goal>compile</goal>
>                         <goal>install</goal -->
>                         <goal>war</goal>
>                         <goal>exploded</goal>
>                         <goal>inplace</goal>
>                     </goals>
>                     <configuration>
> 
> <warSourceDirectory>src/main/webapp</warSourceDirectory>
>                         <webResources>
>                             <resource>
>                                 <directory>src/main/webapp</directory>
>                                 <filtering>true</filtering>
>                                 <includes>
>                                     <include>**/*.jsp</include>
>                                     <include>**/*.xml</include>
>                                     <include>**/*.properties</include>
>                                 </includes>
>                             </resource>
>                         </webResources>
>                      </configuration>
>                 </execution>
>             </executions>
>        </plugin>
>         </plugins>
> 
>     </build>
> 
> the trace of a std build using the install goal is:
> 
> [INFO] [war:war]
> [INFO] Exploding webapp...
> [INFO] Assembling webapp WARTest in
> C:\Java\workspace\TestWARPlugin\target\WARTe
> st-1.0
> [INFO] Copy webapp webResources to
> C:\Java\workspace\TestWARPlugin\target\WARTes
> t-1.0
> [INFO] Generating war
> C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
> [INFO] Building war:
> C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
> [INFO] [war:war {execution: default}]
> [INFO] Exploding webapp...
> [INFO] Assembling webapp WARTest in
> C:\Java\workspace\TestWARPlugin\target\WARTe
> st-1.0
> [INFO] Copy webapp webResources to
> C:\Java\workspace\TestWARPlugin\target\WARTes
> t-1.0
> [INFO] Copy webapp webResources to
> C:\Java\workspace\TestWARPlugin\target\WARTes
> t-1.0
> [INFO] Generating war
> C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
> [INFO] Building war:
> C:\Java\workspace\TestWARPlugin\target\WARTest-1.0.war
> [INFO] [war:exploded {execution: default}]
> WarExplodedMojo by DB
> [INFO] Exploding webapp...
> [INFO] Assembling webapp WARTest in
> C:\Java\workspace\TestWARPlugin\target\WARTe
> st-1.0
> [INFO] Copy webapp webResources to
> C:\Java\workspace\TestWARPlugin\target\WARTes
> t-1.0
> [INFO] Copy webapp webResources to
> C:\Java\workspace\TestWARPlugin\target\WARTes
> t-1.0
> [INFO] [install:install]
> 
> 

-- 
View this message in context: http://www.nabble.com/filtering-resources-in-maven-war-plugin-tf3902334s177.html#a11126738
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org