You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by buildlackey <ch...@gmail.com> on 2010/02/19 05:48:31 UTC

not able to get maven war plugin to filter out unwanted resources from my .war file.


Hi, For some reason this simple little task is making my head spin... 


I am trying to filter out some files from my war using 
<webResources>/<resource>/<excludes>....    But everything i try to exclude
ends up 
being put into the .war.


There does seem to be a bug related to the issue I'm having
(http://jira.codehaus.org/browse/MWAR-198)
hopefully someone can help me with a work-around ?


Here's what i did ...

I created a simple maven web project using mvn archetype:generate.   

Then i added the following lines to the pom (in the build section):

          <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>

                    <webResources>
                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/webapp</directory>
                            <excludes>
                                <exclude>**/*.jsp</exclude>
                            </excludes>
                        </resource>
                    </webResources>

                </configuration>
            </plugin>
          </plugins>


I put in some dummy jsp's in the project for testing, like so:

cbedford@cbedford-laptop: /tmp/trial/findFiles > find . | grep jsp

./src/main/webapp/pig/zooboo.jsp
./src/main/webapp/index.jsp




Then i ran mvn -X install  .. the debug output indicated that the maven-war
plugin 
recognized the file patterns that i specified as 'to be excluded'.. Here is
the output:

[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-war-plugin:2.0.2:war' -->
[DEBUG]   (f) archiveClasses = false
[DEBUG]   (s) classesDirectory = /tmp/trial/findFiles/target/classes
[DEBUG]   (f) filters = []
[DEBUG]   (f) outputDirectory = /tmp/trial/findFiles/target
[DEBUG]   (f) primaryArtifact = true
[DEBUG]   (s) project = MavenProject: com.lackey:findFiles:1.0-SNAPSHOT @
/tmp/trial/findFiles/pom.xml
[DEBUG]   (f) warName = findFiles
[DEBUG]   (s) warSourceDirectory = /tmp/trial/findFiles/src/main/webapp
[DEBUG]   (s) filtering = true
[DEBUG]   (s) directory = src/main/webapp
[DEBUG]   (s) excludes = [**/*.jsp]
[DEBUG]   (f) webResources = [Lorg.apache.maven.model.Resource;@1815338
[DEBUG]   (s) webappDirectory = /tmp/trial/findFiles/target/findFiles
[DEBUG]   (f) workDirectory = /tmp/trial/findFiles/target/war/work
[DEBUG] -- end configuration --




HOWEVER.. when i dumped out the contents of the .war. .the files i was
trying to 
filter were still there (as you can see below.).  




cbedford@cbedford-laptop: /tmp/trial/findFiles > rm -rf  /tmp/jar/*
cbedford@cbedford-laptop: /tmp/trial/findFiles > cp target/findFiles.war 
/tmp/jar
cbedford@cbedford-laptop: /tmp/trial/findFiles > cd !$
cd /tmp/jar
cbedford@cbedford-laptop: /tmp/jar > jar xvf findFiles.war 
  created: META-INF/
 inflated: META-INF/MANIFEST.MF
  created: pig/
  created: WEB-INF/
 inflated: pig/zooboo.jsp       <<<---
 inflated: index.jsp        <<<---
 inflated: zoo.do       
 inflated: WEB-INF/web.xml
  created: META-INF/maven/
  created: META-INF/maven/com.lackey/
  created: META-INF/maven/com.lackey/findFiles/
 inflated: META-INF/maven/com.lackey/findFiles/pom.xml
 inflated: META-INF/maven/com.lackey/findFiles/pom.properties


 
I tried using <includes>...</includes>   as well as <excludes>..  this did
not help at all.



If anyone sees a problem with how i invoked the plugin, or knows of a
work-around, 
please do let me know !  i'd be very grateful. 

thanks !
 chris 



PS:

I tried the work-around in this thread (using packagingExcludes)
http://old.nabble.com/Exclude-subversion-files-in-war-td5288845.html#a5288845

didn't work for me.

-- 
Chris Bedford

Founder & Lead Lackey
Build Lackey Labs:  http://buildlackey.com
Go Grails!: http://groovy.buildlackey.com





-- 
View this message in context: http://old.nabble.com/not-able-to-get-maven-war-plugin-to-filter-out-unwanted-resources-from-my-.war-file.-tp27649724p27649724.html
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


Re: not able to get maven war plugin to filter out unwanted resources from my .war file.

Posted by Wayne Fay <wa...@gmail.com>.
> for production .war's i strip out my environmental properties  and deploy
> them separately, or let the server administrator deal with setting the
> properties...     so some stuff has to be present on the classpath during
> dev, but not production.

If you used multiple war modules and war overlay to insert the
properties into the ones for dev, this would give what you require.

Wayne

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


Re: not able to get maven war plugin to filter out unwanted resources from my .war file.

Posted by buildlackey <ch...@gmail.com>.
Thanks very much to all of you for your help !

I have found a very simple answer, which suggests to me that CURRENT
DOCUMENTATION IS MISSING AN IMPORTANT EXAMPLE.. how to exclude stuff from
the default webapp directory.   I will add this example to the maven user
wiki.. but for closure (i think)  on this topic, here is the trick i used:

 <build>
    <finalName>findFiles</finalName>
          <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1-beta-1</version>
                <configuration>
                    <warSourceExcludes>**/*.jsp</warSourceExcludes>
                </configuration>
            </plugin>
          </plugins>

  </build>

i'm attaching the entire sample project as well. 

  regards . 
  chris 


-- 
Chris Bedford

Founder & Lead Lackey
Build Lackey Labs:  http://buildlackey.com
Go Grails!: http://groovy.buildlackey.com


http://old.nabble.com/file/p27661695/excludeExample.tar.gz
excludeExample.tar.gz 
-- 
View this message in context: http://old.nabble.com/not-able-to-get-maven-war-plugin-to-filter-out-unwanted-resources-from-my-.war-file.-tp27649724p27661695.html
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


Re: not able to get maven war plugin to filter out unwanted resources from my .war file.

Posted by Stephen Connolly <st...@gmail.com>.
On 19 February 2010 17:10, Stephen Connolly <stephen.alan.connolly@gmail.com
> wrote:

> Here is what I would do.
>
> I would have a second war module which has the test files and depend on
> your main module... the automatic war overlaying will ensure that your test
> war has the test resources in addition to the standard resources, and it
> leaves your main module un-sullied by the test stuff
>
>
You could probably achieve the same thing with a second execution of war:war
in your main project (only attaching with classifier test) but, that is
distinctly un-maven-like (and therefore a bad plan^H^H^H^H^H^H^H^Hhack)


> -Stephen
>
>
> On 19 February 2010 16:55, buildlackey <ch...@gmail.com> wrote:
>
>>
>>
>> well, i could attach an ant run script (that does the file moving)
>> to the prepare-package phase... but unfortunately there is no post-package
>> phase..
>> this means that if anyone runs 'package'  the files would be moved from
>> where they need to be during dev/test phases, and never moved back.
>>
>> for production .war's i strip out my environmental properties  and deploy
>> them separately, or let the server administrator deal with setting the
>> properties...     so some stuff has to be present on the classpath during
>> dev, but not production.
>>
>> So, good idea in theory.. .but because of the lack of a post-package
>> phase..
>> it opens the build script to behaving strangely.
>>
>> thanks in any case for your response !
>>  chris
>>
>>
>>
>> --
>> Chris Bedford
>>
>> Founder & Lead Lackey
>> Build Lackey Labs:  http://buildlackey.com
>> Go Grails!: http://groovy.buildlackey.com
>>
>>
>>
>>
>>
>> Wayne Fay wrote:
>> >
>> >> If anyone sees a problem with how i invoked the plugin, or knows of a
>> >> work-around,
>> >> please do let me know !  i'd be very grateful.
>> >
>> > Well... an obvious workaround would be to simply move the files to a
>> > directory not being packaged by Maven, or just delete them. I am
>> > guessing this is not acceptable for some reason.
>> >
>> > Wayne
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> > For additional commands, e-mail: users-help@maven.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/not-able-to-get-maven-war-plugin-to-filter-out-unwanted-resources-from-my-.war-file.-tp27649724p27656990.html
>> 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
>>
>>
>

Re: not able to get maven war plugin to filter out unwanted resources from my .war file.

Posted by Stephen Connolly <st...@gmail.com>.
[ASIDE]

ehhh...

you do know that if you run

mvn integration-test

then the post-integration-test phase will _never_ be run

the correct solution to the above is to not run mvn integration-test but run
mvn verify instead (and bonus, it's shorter)

I only mention because you seem to (mistakenly) think having a post-package
phase would help you

[/ASIDE]

Here is what I would do.

I would have a second war module which has the test files and depend on your
main module... the automatic war overlaying will ensure that your test war
has the test resources in addition to the standard resources, and it leaves
your main module un-sullied by the test stuff

-Stephen

On 19 February 2010 16:55, buildlackey <ch...@gmail.com> wrote:

>
>
> well, i could attach an ant run script (that does the file moving)
> to the prepare-package phase... but unfortunately there is no post-package
> phase..
> this means that if anyone runs 'package'  the files would be moved from
> where they need to be during dev/test phases, and never moved back.
>
> for production .war's i strip out my environmental properties  and deploy
> them separately, or let the server administrator deal with setting the
> properties...     so some stuff has to be present on the classpath during
> dev, but not production.
>
> So, good idea in theory.. .but because of the lack of a post-package
> phase..
> it opens the build script to behaving strangely.
>
> thanks in any case for your response !
>  chris
>
>
>
> --
> Chris Bedford
>
> Founder & Lead Lackey
> Build Lackey Labs:  http://buildlackey.com
> Go Grails!: http://groovy.buildlackey.com
>
>
>
>
>
> Wayne Fay wrote:
> >
> >> If anyone sees a problem with how i invoked the plugin, or knows of a
> >> work-around,
> >> please do let me know !  i'd be very grateful.
> >
> > Well... an obvious workaround would be to simply move the files to a
> > directory not being packaged by Maven, or just delete them. I am
> > guessing this is not acceptable for some reason.
> >
> > Wayne
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/not-able-to-get-maven-war-plugin-to-filter-out-unwanted-resources-from-my-.war-file.-tp27649724p27656990.html
> 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
>
>

Re: not able to get maven war plugin to filter out unwanted resources from my .war file.

Posted by buildlackey <ch...@gmail.com>.

well, i could attach an ant run script (that does the file moving) 
to the prepare-package phase... but unfortunately there is no post-package
phase.. 
this means that if anyone runs 'package'  the files would be moved from
where they need to be during dev/test phases, and never moved back.

for production .war's i strip out my environmental properties  and deploy
them separately, or let the server administrator deal with setting the
properties...     so some stuff has to be present on the classpath during
dev, but not production. 

So, good idea in theory.. .but because of the lack of a post-package phase..
it opens the build script to behaving strangely.

thanks in any case for your response !
 chris 



-- 
Chris Bedford

Founder & Lead Lackey
Build Lackey Labs:  http://buildlackey.com
Go Grails!: http://groovy.buildlackey.com





Wayne Fay wrote:
> 
>> If anyone sees a problem with how i invoked the plugin, or knows of a
>> work-around,
>> please do let me know !  i'd be very grateful.
> 
> Well... an obvious workaround would be to simply move the files to a
> directory not being packaged by Maven, or just delete them. I am
> guessing this is not acceptable for some reason.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/not-able-to-get-maven-war-plugin-to-filter-out-unwanted-resources-from-my-.war-file.-tp27649724p27656990.html
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


Re: not able to get maven war plugin to filter out unwanted resources from my .war file.

Posted by Wayne Fay <wa...@gmail.com>.
> If anyone sees a problem with how i invoked the plugin, or knows of a
> work-around,
> please do let me know !  i'd be very grateful.

Well... an obvious workaround would be to simply move the files to a
directory not being packaged by Maven, or just delete them. I am
guessing this is not acceptable for some reason.

Wayne

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