You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "KARR, DAVID (ATTSI)" <dk...@att.com> on 2010/05/20 17:14:50 UTC

How to put all jars in a path variable (minus some exclusions) into WEB-INF/lib?

I have a "build.classpath" path variable.  I want all of the jars, but
not the classes, and minus some specific exclusions, to be put into my
WEB-INF/lib.  All of the jars specified there are stored in a specific
directory, but I don't know that I want to depend on that.

I have a "war" element, and a "lib" element below that.  I can use a
'includes="*.jar"' attribute and add exclusions for all the jars that I
don't want to include, but I'd really rather just have exclusions from
the "build.classpath" path variable.  This would include any specific
elements in that variable that refer to "classes" dirs, and any jars
that are implicit in the container.  If I can do it this way, it makes
it much easier to test varying versions of certain packages.  I can have
both versions in my "lib" directory, and just change a properties file
reference, and not even change the build.xml.  Without this capability,
I have to change both the properties file and the exclusions in the
"lib" element.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to put all jars in a path variable (minus some exclusions) into WEB-INF/lib?

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello David,

you can create a path from your build.classpath variable.

I think with the copy task and the resource collections framework you can achieve what you want

this snippet (untested) would copy all jars in build.classpath to WEB-INF/lib. You can easily add some code to exclude other specific jars from the copy, by nesting <rsel:name inside <rsel:and and adding other conditions.

<project rsel="antlib:org.apache.tools.ant.types.resources.selectors">
<copy todir="WEB-INF/lib">
  <restrict>
    <path>
       <pathelement path="${build.classpath}"/> 
    </path>
    <rsel:name name="*.jar"/>
    <flattenmapper/>
  </restrict>
<copy>
</project>

Hope this helps,

Antoine

-------- Original-Nachricht --------
> Datum: Thu, 20 May 2010 08:14:50 -0700
> Von: "KARR, DAVID (ATTSI)" <dk...@att.com>
> An: "Ant Users List" <us...@ant.apache.org>
> Betreff: How to put all jars in a path variable (minus some exclusions) into WEB-INF/lib?

> I have a "build.classpath" path variable.  I want all of the jars, but
> not the classes, and minus some specific exclusions, to be put into my
> WEB-INF/lib.  All of the jars specified there are stored in a specific
> directory, but I don't know that I want to depend on that.
> 
> I have a "war" element, and a "lib" element below that.  I can use a
> 'includes="*.jar"' attribute and add exclusions for all the jars that I
> don't want to include, but I'd really rather just have exclusions from
> the "build.classpath" path variable.  This would include any specific
> elements in that variable that refer to "classes" dirs, and any jars
> that are implicit in the container.  If I can do it this way, it makes
> it much easier to test varying versions of certain packages.  I can have
> both versions in my "lib" directory, and just change a properties file
> reference, and not even change the build.xml.  Without this capability,
> I have to change both the properties file and the exclusions in the
> "lib" element.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org