aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark ""Exclude" does not seem to be working when building WAR" Watch ""Exclude" does not seem to be working when building WAR" New topic
Author

"Exclude" does not seem to be working when building WAR

Stephen McConnell
Greenhorn

Joined: Mar 23, 2010
Posts: 19
I am building a war and have a library under the "WEB-INF/lib" directory. While compiling, I have the "javax.servlet.jar" in that lib, but when I build the war file, I want to exclude it from the "lib" folder.

Under the "war" task here's what I do...



It builds the war, but does not exclude "javax.servlet.jar" like the "docs" said.

Que Passo, here?

Stephen McConnell


Stephen McConnell

"Boredom is a personal defect"
-- Lamar Stephens
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Is ${temp.dir.lib} a subdirectory under ${temp.dir}? If so, I think that the servlet jar is being included based on the basedir specified in the <war> task. I would recommend placing ${temp.dir.lib} in a different physical location. (Actually, I really recommend using the Maven project structure, but that is a different topic...)

One more thought - run with the -v option, that might give more clues as to how the jars are being included/excluded.


JBoss In Action
Stephen McConnell
Greenhorn

Joined: Mar 23, 2010
Posts: 19
(Actually, I really recommend using the Maven project structure, but that is a different topic...).


I wish they would.... but they don't use maven here.

Steve
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Stephen McConnell wrote:I wish they would.... but they don't use maven here.

That's not a requirement for using the Maven directory structure.

That aside, I wouldn't have that library in WEB-INF/lib at all, but instead keep it as an external dependency.
Stephen McConnell
Greenhorn

Joined: Mar 23, 2010
Posts: 19
[quote=David Newton
That aside, I wouldn't have that library in WEB-INF/lib at all, but instead keep it as an external dependency.

I probably will do just that.

It is still troubling that I have found several posts under other forums that discuss "exclude" not doing what it said it is supposed to do and none explain why it does not work like several examples in the documentation.

Stephen McConnell
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Isn't the element "excludes", not "exclude"?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Good question, David. In the docs the table showing the options uses excludes while all the examples use exclude.
http://ant.apache.org/manual/CoreTypes/fileset.html
('lib' is a type of 'fileset')
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Hmm, that's weird.
Stephen McConnell
Greenhorn

Joined: Mar 23, 2010
Posts: 19
"Lib" doesn't support the excludes option (Straight from the Ant build).
 
wood burning stoves
 
subject: "Exclude" does not seem to be working when building WAR
 
Similar Threads
Strange Ant Behavior
GWT .war file building problem (Ant Build)
Error while running "war" task (Resolved)
Where should I put the jar? java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
class files not in the War