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 <[EMAIL PROTECTED]>
Software Engineer
Teaching & Learning Centre
University of Calgary
http://tlc.ucalgary.ca