You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Julian Wood <wo...@ucalgary.ca> on 2007/03/01 00:36:24 UTC
War resource filtering and excludes problem.
In my src/main/webapp/WEB-INF I have a classes folder and a lib
folder, which are not part of the source, but let me compile in place
and immediately see the results of my changes in tomcat.
Now when I go to actually build a war using maven, I don't want that
lib nor classes folder - I want the one which maven generates. In its
default state, using version 2.0.2 of the war plugin, what happens is
that you get both sets - in the lib folder for example, you get
everything in my "dev" lib folder, plus any new snapshots or new
dependencies maven might have downloaded. So usually you end up with
duplicate jars. Not good.
How do you tell the war plugin to ignore src/main/webapp/WEB-INF/lib
and classes (but not ignore the ones assembled during compilation)?
No matter what configuration I use, it always either ignores both
sets, or includes both sets. Here is an example:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<excludes>**/WEB-INF/lib/*</excludes>
</configuration>
</plugin>
or
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceExcludes>WEB-INF/lib/*.*,WEB-INF/classes/**/*.*</
warSourceExcludes>
</configuration>
</plugin>
Thanks,
J
--
Julian Wood <wo...@ucalgary.ca>
Software Engineer
Teaching & Learning Centre
University of Calgary
http://tlc.ucalgary.ca
Re: War resource filtering and excludes problem.
Posted by Julian Wood <wo...@ucalgary.ca>.
Adding that clean configuration works perfectly for what I want to
do. The mvn compile war:inplace is a nice hint as well, though I did
notice that it doesn't run my filters on resources going into the
classes dir, as it does when you just do a mvn clean package. But
that's not too big a deal - the clean config is what I was looking for.
Thanks!
J
On 2-Mar-07, at 2:10 PM, Greg_Vaughn@Countrywide.Com wrote:
> I'm wondering if a whole 'nother approach would work for you. It
> really
> depends on your workflow, but I submit it for your consideration.
>
> Doing 'mvn compile war:inplace' will cause maven to copy the .class
> files
> to web-inf/classes and the pom dependencies to web-inf/lib so that
> you can
> do your gui testing in place. I'd also suggest setting up your source
> control to ignore these folders. I've done it with subversion, but
> don't
> recall the syntax.
>
> To go a step further, add those directories to the 'clean' plugin
> in your
> pom like this:
> <plugin>
> <artifactId>maven-clean-plugin</artifactId>
> <configuration>
> <filesets>
> <fileset>
> <directory>${basedir}/src/main/webapp/WEB-INF/lib</directory>
> </fileset>
> <fileset>
> <directory>${basedir}/src/main/webapp/WEB-INF/classes</directory>
> </fileset>
> </filesets>
> </configuration>
> </plugin>
>
> Now you can do 'mvn clean package' to get a pristine war.
>
> Does that meet your overall goal?
>
> -Greg Vaughn
>
> "Julian
--
Julian Wood <wo...@ucalgary.ca>
Software Engineer
Teaching & Learning Centre
University of Calgary
http://tlc.ucalgary.ca
Re: War resource filtering and excludes problem.
Posted by Gr...@Countrywide.Com.
I'm wondering if a whole 'nother approach would work for you. It really
depends on your workflow, but I submit it for your consideration.
Doing 'mvn compile war:inplace' will cause maven to copy the .class files
to web-inf/classes and the pom dependencies to web-inf/lib so that you can
do your gui testing in place. I'd also suggest setting up your source
control to ignore these folders. I've done it with subversion, but don't
recall the syntax.
To go a step further, add those directories to the 'clean' plugin in your
pom like this:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${basedir}/src/main/webapp/WEB-INF/lib</directory>
</fileset>
<fileset>
<directory>${basedir}/src/main/webapp/WEB-INF/classes</directory>
</fileset>
</filesets>
</configuration>
</plugin>
Now you can do 'mvn clean package' to get a pristine war.
Does that meet your overall goal?
-Greg Vaughn
"Julian Wood" <wo...@ucalgary.ca> wrote on 03/02/2007 02:35:48 PM:
> I'm actually beginning to think this is not possible with the way the
> war plugin currently works. You are always going to have either both
> sets of jars, or neither set. The reason is because the war plugin
> seems to do its excludes at the last possible moment, so it can't
> differentiate between the two sources.
>
> I think the pom snippet which should work is this one:
>
> <configuration>
> <warSourceExcludes>**/*.jar</warSourceExcludes>
> </configuration>
>
> I execute mvn clean package
>
> In the target folder, in the "webappDirectory" in maven-war-plugin
> nomenclature (http://maven.apache.org/plugins/maven-war-plugin/war-
> mojo.html), it creates the perfect webapp (minus the META-INF). That
> is, it has everything from src/main/webapp, with the exception of any
> jars from src/main/webapp/lib. It does have a lib directory,
> assembled from the dependencies in the pom. This is seldom identical
> to the lib directory at src/main/webapp/lib, but that's okay (that's
> the point, actually). This webapp works perfectly.
>
> Now unfortunately, the war plugin doesn't simply make a war from that
> directory it just built. First it wars it, then it grabs all the
> files from src/main/webapp again, and then it applies any excludes
> (again). So in this situation, I get no jars at all in the lib folder
> of the final war file.
>
> That's why if I specify no excludes at all, I get all the jars from
> the src/main/webapp/lib and all the jars from the dependencies.
>
> I'm not sure if this should be labeled a bug with the war plugin or
> not. I haven't looked at the code - it is all surmised from what it
> produces.
>
> I think my best bet might be to do an antrun to move the lib folder
> before the war is generated, and move it back afterwards, which is
> what I do manually right now.
>
> Thanks,
>
> J
>
>
>
> On 28-Feb-07, at 4:36 PM, Julian Wood wrote:
>
> > In my src/main/webapp/WEB-INF I have a classes folder and a lib
> > folder, which are not part of the source, but let me compile in
> > place and immediately see the results of my changes in tomcat.
> >
> > Now when I go to actually build a war using maven, I don't want
> > that lib nor classes folder - I want the one which maven generates.
> > In its default state, using version 2.0.2 of the war plugin, what
> > happens is that you get both sets - in the lib folder for example,
> > you get everything in my "dev" lib folder, plus any new snapshots
> > or new dependencies maven might have downloaded. So usually you end
> > up with duplicate jars. Not good.
> >
> > How do you tell the war plugin to ignore src/main/webapp/WEB-INF/
> > lib and classes (but not ignore the ones assembled during
> > compilation)?
> >
> > No matter what configuration I use, it always either ignores both
> > sets, or includes both sets.
> >
> > Thanks,
> >
> > J
> >
>
> --
> Julian Wood <wo...@ucalgary.ca>
>
> Software Engineer
> Teaching & Learning Centre
> University of Calgary
>
> http://tlc.ucalgary.ca
>
>
======================================================================
Confidentiality Notice: The information contained in and transmitted with this communication is strictly confidential, is intended only for the use of the intended recipient, and is the property of Countrywide Financial Corporation or its affiliates and subsidiaries. If you are not the intended recipient, you are hereby notified that any use of the information contained in or transmitted with the communication or dissemination, distribution, or copying of this communication is strictly prohibited by law. If you have received this communication in error, please immediately return this communication to the sender and delete the original message and any copy of it in your possession.
======================================================================
Re: War resource filtering and excludes problem.
Posted by Julian Wood <wo...@ucalgary.ca>.
I'm actually beginning to think this is not possible with the way the
war plugin currently works. You are always going to have either both
sets of jars, or neither set. The reason is because the war plugin
seems to do its excludes at the last possible moment, so it can't
differentiate between the two sources.
I think the pom snippet which should work is this one:
<configuration>
<warSourceExcludes>**/*.jar</warSourceExcludes>
</configuration>
I execute mvn clean package
In the target folder, in the "webappDirectory" in maven-war-plugin
nomenclature (http://maven.apache.org/plugins/maven-war-plugin/war-
mojo.html), it creates the perfect webapp (minus the META-INF). That
is, it has everything from src/main/webapp, with the exception of any
jars from src/main/webapp/lib. It does have a lib directory,
assembled from the dependencies in the pom. This is seldom identical
to the lib directory at src/main/webapp/lib, but that's okay (that's
the point, actually). This webapp works perfectly.
Now unfortunately, the war plugin doesn't simply make a war from that
directory it just built. First it wars it, then it grabs all the
files from src/main/webapp again, and then it applies any excludes
(again). So in this situation, I get no jars at all in the lib folder
of the final war file.
That's why if I specify no excludes at all, I get all the jars from
the src/main/webapp/lib and all the jars from the dependencies.
I'm not sure if this should be labeled a bug with the war plugin or
not. I haven't looked at the code - it is all surmised from what it
produces.
I think my best bet might be to do an antrun to move the lib folder
before the war is generated, and move it back afterwards, which is
what I do manually right now.
Thanks,
J
On 28-Feb-07, at 4:36 PM, Julian Wood wrote:
> In my src/main/webapp/WEB-INF I have a classes folder and a lib
> folder, which are not part of the source, but let me compile in
> place and immediately see the results of my changes in tomcat.
>
> Now when I go to actually build a war using maven, I don't want
> that lib nor classes folder - I want the one which maven generates.
> In its default state, using version 2.0.2 of the war plugin, what
> happens is that you get both sets - in the lib folder for example,
> you get everything in my "dev" lib folder, plus any new snapshots
> or new dependencies maven might have downloaded. So usually you end
> up with duplicate jars. Not good.
>
> How do you tell the war plugin to ignore src/main/webapp/WEB-INF/
> lib and classes (but not ignore the ones assembled during
> compilation)?
>
> No matter what configuration I use, it always either ignores both
> sets, or includes both sets.
>
> Thanks,
>
> J
>
--
Julian Wood <wo...@ucalgary.ca>
Software Engineer
Teaching & Learning Centre
University of Calgary
http://tlc.ucalgary.ca
Re: War resource filtering and excludes problem.
Posted by Julian Wood <wo...@ucalgary.ca>.
Hi Chris,
Isn't this for use with war overlays? The way I understood this from
the documentation was that if the module you're building depends on
the creation of another war in your project, you can use this to
combine the two wars, into a single war, excluding whatever you want
from the war dependency. But maybe I'm wrong.
Anyways, trying this solution in my case, which is just a single war
artifact, doesn't exclude anything, which is expected if I
interpreted the documentation correctly. I even tried **/*.jar, and
nothing is excluded (which I would expect). Maybe you're using it
properly in a war overlay?
Thanks,
J
On 2-Mar-07, at 3:11 AM, Chris Miner wrote:
> Hi Julian,
>
> I do something similar for a war build with maven 2.x. Here's my
> pom snippet:
>
> <build>
> <plugins>
> <plugin>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <dependentWarExcludes>WEB-INF/lib/*.jar</
> dependentWarExcludes>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> Cheers,
> Chris
>
> Am Donnerstag, 1. März 2007 18:23 schrieb Julian Wood:
>> Hi Seetamraju,
>>
>> Thanks for the suggestions. I tried both patterns you suggested but
>> neither of them exclude anything at all. In other words, maven-war
>> still grabs the lib folder from src/main/webapp/WEB-INF and the lib
>> folder from what it builds in the target dir and combines them.
>>
>> <plugin>
>> <artifactId>maven-war-plugin</artifactId>
>> <version>2.0.2</version>
>> <configuration>
>> <excludes>**/WEB-INF/lib</excludes>
>> </configuration>
>> </plugin>
>>
>> Thanks,
>>
>> J
>>
>> On 28-Feb-07, at 8:05 PM, Seetamraju Udaybhaskar Sarma wrote:
>>> Try src/main/webapp/WEB-INF/lib ---or--- **/WEB-INF/lib
>>> I don't think '*' is allowed within excludes.
>>> I am sure you do not want the LIB subfolder either (in which case
>>> WEB-INF/lib/* is not what you wanna write).
>>>
>>> Julian Wood wrote:
>>>> <plugin>
>>>> <artifactId>maven-war-plugin</artifactId>
>>>> <configuration>
>>>> <excludes>**/WEB-INF/lib/*</excludes>
>>>> </configuration>
>>>> </plugin>
>>>>
>>>> or
>>>>
>>>> <plugin>
>>>> <artifactId>maven-war-plugin</artifactId>
>>>> <configuration>
>>>>
>>>> <warSourceExcludes>WEB-INF/lib/*.*,WEB-INF/classes/**/*.*</
>>>> warSourceExcludes>
>>>>
>>>> </configuration>
>>>> </plugin>
--
Julian Wood <wo...@ucalgary.ca>
Software Engineer
Teaching & Learning Centre
University of Calgary
http://tlc.ucalgary.ca
Re: War resource filtering and excludes problem.
Posted by Chris Miner <ch...@luxoom.com>.
Hi Julian,
I do something similar for a war build with maven 2.x. Here's my pom snippet:
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<dependentWarExcludes>WEB-INF/lib/*.jar</dependentWarExcludes>
</configuration>
</plugin>
</plugins>
</build>
Cheers,
Chris
Am Donnerstag, 1. März 2007 18:23 schrieb Julian Wood:
> Hi Seetamraju,
>
> Thanks for the suggestions. I tried both patterns you suggested but
> neither of them exclude anything at all. In other words, maven-war
> still grabs the lib folder from src/main/webapp/WEB-INF and the lib
> folder from what it builds in the target dir and combines them.
>
> <plugin>
> <artifactId>maven-war-plugin</artifactId>
> <version>2.0.2</version>
> <configuration>
> <excludes>**/WEB-INF/lib</excludes>
> </configuration>
> </plugin>
>
> Thanks,
>
> J
>
> On 28-Feb-07, at 8:05 PM, Seetamraju Udaybhaskar Sarma wrote:
> > Try src/main/webapp/WEB-INF/lib ---or--- **/WEB-INF/lib
> > I don't think '*' is allowed within excludes.
> > I am sure you do not want the LIB subfolder either (in which case
> > WEB-INF/lib/* is not what you wanna write).
> >
> > Julian Wood wrote:
> >> <plugin>
> >> <artifactId>maven-war-plugin</artifactId>
> >> <configuration>
> >> <excludes>**/WEB-INF/lib/*</excludes>
> >> </configuration>
> >> </plugin>
> >>
> >> or
> >>
> >> <plugin>
> >> <artifactId>maven-war-plugin</artifactId>
> >> <configuration>
> >>
> >> <warSourceExcludes>WEB-INF/lib/*.*,WEB-INF/classes/**/*.*</
> >> warSourceExcludes>
> >>
> >> </configuration>
> >> </plugin>
>
> --
> Julian Wood <wo...@ucalgary.ca>
>
> Software Engineer
> Teaching & Learning Centre
> University of Calgary
>
> http://tlc.ucalgary.ca
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: War resource filtering and excludes problem.
Posted by Julian Wood <wo...@ucalgary.ca>.
Hi Seetamraju,
Thanks for the suggestions. I tried both patterns you suggested but
neither of them exclude anything at all. In other words, maven-war
still grabs the lib folder from src/main/webapp/WEB-INF and the lib
folder from what it builds in the target dir and combines them.
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<excludes>**/WEB-INF/lib</excludes>
</configuration>
</plugin>
Thanks,
J
On 28-Feb-07, at 8:05 PM, Seetamraju Udaybhaskar Sarma wrote:
> Try src/main/webapp/WEB-INF/lib ---or--- **/WEB-INF/lib
> I don't think '*' is allowed within excludes.
> I am sure you do not want the LIB subfolder either (in which case
> WEB-INF/lib/* is not what you wanna write).
>
> Julian Wood wrote:
>> <plugin>
>> <artifactId>maven-war-plugin</artifactId>
>> <configuration>
>> <excludes>**/WEB-INF/lib/*</excludes>
>> </configuration>
>> </plugin>
>>
>> or
>>
>> <plugin>
>> <artifactId>maven-war-plugin</artifactId>
>> <configuration>
>>
>> <warSourceExcludes>WEB-INF/lib/*.*,WEB-INF/classes/**/*.*</
>> warSourceExcludes>
>>
>> </configuration>
>> </plugin>
>
>
--
Julian Wood <wo...@ucalgary.ca>
Software Engineer
Teaching & Learning Centre
University of Calgary
http://tlc.ucalgary.ca