You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by hezjing <he...@gmail.com> on 2007/07/10 04:21:15 UTC

Create WEB-INF/lib based on path-structure

Hi

I have a path structure containing a list of JARs, saved at the shared
repository.

How can I inlucde these JARs into WEB-INF/lib when creating a WAR
file, without copying the JARs into local project directory?


-- 

Hez

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


Re: Create WEB-INF/lib based on path-structure

Posted by Peter Reilly <pe...@gmail.com>.
Just use the <jar> task.

Peter

On Jan 25, 2008 8:37 PM, Wszeb <ws...@gmail.com> wrote:
>
>
>
> DATACOM - Diego-2 wrote:
> >
> > Hmmm, the guy said he had a "path structure", not a "fileset" (look
> > subject of the message). Unfortunately, if he cannot change his path
> > into a fileset, I think he is in trouble. I had exactly the same
> > problem with the War task.
> >
> > All these bugs seem to be related with this problem (does anyone know
> > anything about their status?):
> >
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=31947
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=34830
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=4240
> >
> > There has also been a lot of requests about this on the list:
> >
> > http://marc.info/?l=ant-user&m=116361854515417&w=2
> > http://marc.info/?l=ant-user&m=114002246007998&w=2
> > http://marc.info/?l=ant-user&m=113812618105463&w=2
> > http://marc.info/?l=ant-user&m=113527002416136&w=2
> > http://marc.info/?l=ant-user&m=112357685822564&w=2
> > http://marc.info/?l=ant-user&m=112327124415275&w=2
> > http://marc.info/?l=ant-user&m=108903488203940&w=2
> > http://marc.info/?l=ant-user&m=106614424001052&w=2
> > http://marc.info/?l=ant-user&m=106548189107671&w=2
> > http://marc.info/?l=ant-user&m=106062985323218&w=2
> > http://marc.info/?l=ant-user&m=104257138003228&w=2
> > http://marc.info/?l=ant-user&m=98813243932680&w=2
> > http://marc.info/?l=ant-user&m=98088337825990&w=2
> >
> > It is a really annoying "feature" of the War task.
> >
>
> Does anybody know the good workaround solution for "<lib> in <war> does not
> accept path-like structures" problem? Is it possible to somehow specify with
> a path-like structure a set of JARs (from various disk locations) to be
> placed in WAR ?
>
> There is also a similar thread on ant-dev list:
> http://www.nabble.com/Lib-in-War-Does-Not-Accept-Path-like-structures-to14654383.html
> --
> View this message in context: http://www.nabble.com/Create-WEB-INF-lib-based-on-path-structure-tp11513835p15096305.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
>
> ---------------------------------------------------------------------
> 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


Re: Create WEB-INF/lib based on path-structure

Posted by Wszeb <ws...@gmail.com>.

DATACOM - Diego-2 wrote:
> 
> Hmmm, the guy said he had a "path structure", not a "fileset" (look 
> subject of the message). Unfortunately, if he cannot change his path 
> into a fileset, I think he is in trouble. I had exactly the same 
> problem with the War task.
> 
> All these bugs seem to be related with this problem (does anyone know 
> anything about their status?):
> 
> http://issues.apache.org/bugzilla/show_bug.cgi?id=31947
> http://issues.apache.org/bugzilla/show_bug.cgi?id=34830
> http://issues.apache.org/bugzilla/show_bug.cgi?id=4240
> 
> There has also been a lot of requests about this on the list:
> 
> http://marc.info/?l=ant-user&m=116361854515417&w=2
> http://marc.info/?l=ant-user&m=114002246007998&w=2
> http://marc.info/?l=ant-user&m=113812618105463&w=2
> http://marc.info/?l=ant-user&m=113527002416136&w=2
> http://marc.info/?l=ant-user&m=112357685822564&w=2
> http://marc.info/?l=ant-user&m=112327124415275&w=2
> http://marc.info/?l=ant-user&m=108903488203940&w=2
> http://marc.info/?l=ant-user&m=106614424001052&w=2
> http://marc.info/?l=ant-user&m=106548189107671&w=2
> http://marc.info/?l=ant-user&m=106062985323218&w=2
> http://marc.info/?l=ant-user&m=104257138003228&w=2
> http://marc.info/?l=ant-user&m=98813243932680&w=2
> http://marc.info/?l=ant-user&m=98088337825990&w=2
> 
> It is a really annoying "feature" of the War task.
> 

Does anybody know the good workaround solution for "<lib> in <war> does not
accept path-like structures" problem? Is it possible to somehow specify with
a path-like structure a set of JARs (from various disk locations) to be
placed in WAR ?

There is also a similar thread on ant-dev list:
http://www.nabble.com/Lib-in-War-Does-Not-Accept-Path-like-structures-to14654383.html
-- 
View this message in context: http://www.nabble.com/Create-WEB-INF-lib-based-on-path-structure-tp11513835p15096305.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: Create WEB-INF/lib based on path-structure

Posted by DATACOM - Diego <di...@datacom.ind.br>.
Hmmm, the guy said he had a "path structure", not a "fileset" (look 
subject of the message). Unfortunately, if he cannot change his path 
into a fileset, I think he is in trouble. I had exactly the same 
problem with the War task.

All these bugs seem to be related with this problem (does anyone know 
anything about their status?):

http://issues.apache.org/bugzilla/show_bug.cgi?id=31947
http://issues.apache.org/bugzilla/show_bug.cgi?id=34830
http://issues.apache.org/bugzilla/show_bug.cgi?id=4240

There has also been a lot of requests about this on the list:

http://marc.info/?l=ant-user&m=116361854515417&w=2
http://marc.info/?l=ant-user&m=114002246007998&w=2
http://marc.info/?l=ant-user&m=113812618105463&w=2
http://marc.info/?l=ant-user&m=113527002416136&w=2
http://marc.info/?l=ant-user&m=112357685822564&w=2
http://marc.info/?l=ant-user&m=112327124415275&w=2
http://marc.info/?l=ant-user&m=108903488203940&w=2
http://marc.info/?l=ant-user&m=106614424001052&w=2
http://marc.info/?l=ant-user&m=106548189107671&w=2
http://marc.info/?l=ant-user&m=106062985323218&w=2
http://marc.info/?l=ant-user&m=104257138003228&w=2
http://marc.info/?l=ant-user&m=98813243932680&w=2
http://marc.info/?l=ant-user&m=98088337825990&w=2

It is a really annoying "feature" of the War task.

Diego

Prashant Reddy escreveu:
> On Tue, 2007-07-10 at 12:25 +0530, Prashant Reddy wrote:
>>>> Based on http://ant.apache.org/manual/CoreTypes/fileset.html, how
>> do
>>>> we know the element supports "refid" attribute?
> 
> The relevant documentation seem to be here :
> 
> http://ant.apache.org/manual/dirtasks.html#patterns
> 
> "We said that Directory-based tasks can sometimes act as an implicit
> <fileset>, but in addition to that, a FileSet acts as an implicit
> <patternset>."
> 
> So because fileset is implicit patternset, it can have an 'id'
> attribute.
> 

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


Re: Create WEB-INF/lib based on path-structure

Posted by Prashant Reddy <pr...@pramati.com>.
On Tue, 2007-07-10 at 12:25 +0530, Prashant Reddy wrote:
> >> Based on http://ant.apache.org/manual/CoreTypes/fileset.html, how
> do
> >> we know the element supports "refid" attribute?
> 

The relevant documentation seem to be here :

http://ant.apache.org/manual/dirtasks.html#patterns

"We said that Directory-based tasks can sometimes act as an implicit
<fileset>, but in addition to that, a FileSet acts as an implicit
<patternset>."

So because fileset is implicit patternset, it can have an 'id'
attribute.

-- 

-Prashant

Don't upload, just share : www.dekoh.com


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


Re: Create WEB-INF/lib based on path-structure

Posted by Prashant Reddy <pr...@pramati.com>.
On Tue, 2007-07-10 at 14:29 +0800, hezjing wrote:
>> Based on http://ant.apache.org/manual/CoreTypes/fileset.html, how do
>> we know the element supports "refid" attribute?

You mean the 'id' attribute, right ?

Yes you are correct the documentation of fileset does not specify
support for id attribute. While using <patternset id="base.path"> inside
a <fileset> as the sample documented, makes WAR task give out error 
"base.path doesn't denote a zipfileset or a fileset"

> > >   <path id="base.path">
> > >   <fileset dir="lib">
> > >   <include name="**/*.jar"/>
> > >   </fileset>
> > >   </path> 

However, adding "id" attribute to <fileset> seems to be allowed.

<project name="wartasktest">

<fileset dir="lib" id="base.path">
	<include name="**/*.jar"/>
</fileset>

<target name="dist">
	<war jarfile="${war.filename}" webxml="${WEB-INF}/web.xml">
            <lib refid="base.path"/>
        </war>
</target>
</project>

I have tried this out, and executing target 'dist' did create WAR file
including all the jars referenced in base.path in WEB-INF/lib. I am
using ant version 1.6.2.

-- 

-Prashant

Don't upload, just share : www.dekoh.com


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


Re: Create WEB-INF/lib based on path-structure

Posted by hezjing <he...@gmail.com>.
Yes, I should have use the modern IDE to see the available attributes.

Based on http://ant.apache.org/manual/CoreTypes/fileset.html, how do
we know the element supports "refid" attribute?

When run with <lib refid="base.path" />, Ant complaints that the
"base.path doesn't denote a zipfileset or a fileset"

Did I miss out anything here?


On 7/10/07, Prashant Reddy <pr...@pramati.com> wrote:
> On Tue, 2007-07-10 at 14:06 +0800, hezjing wrote:
> > Hi Prashant
> >
> > Thanks for the WAR task description.
> >
> > If I have a path-like structure called "base.path",
> >
> >   <path id="base.path">
> >   <fileset dir="lib">
> >   <include name="**/*.jar"/>
> >   </fileset>
> >   </path>
> >
> > How can I referencing "base.path" directly in <war> task or it's
> > nested <lib> element?
>
> WAR task specifies in the documentation that :
>
> "The nested lib element specifies a FileSet. All files included in this
> fileset will end up in the WEB-INF/lib directory of the war file."
>
> So try :
> <lib refid="base.path">
>
> Actually if you are using modern IDE (like IDEA) to edit your build.xml
> typing "<lib" should fire-up all possible options to auto-complete.
>
> Hope this helps.
>
> >
> >
> >
> >
> > On 7/10/07, Prashant Reddy <pr...@pramati.com> wrote:
> > > Take a look at 'war' task at :
> > > http://ant.apache.org/manual/CoreTasks/war.html
> > >
> > > Examples given in this page should address your concern.
> > >
> > > On Tue, 2007-07-10 at 10:21 +0800, hezjing wrote:
> > > > Hi
> > > >
> > > > I have a path structure containing a list of JARs, saved at the shared
> > > > repository.
> > > >
> > > > How can I inlucde these JARs into WEB-INF/lib when creating a WAR
> > > > file, without copying the JARs into local project directory?
> > > >
> > > >
> > > --
> > >
> > > -Prashant
> > >
> > > Don't upload, just share : www.dekoh.com
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > >
> >
> >
> --
>
> -Prashant
>
> Don't upload, just share : www.dekoh.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 

Hez

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


Re: Create WEB-INF/lib based on path-structure

Posted by Prashant Reddy <pr...@pramati.com>.
On Tue, 2007-07-10 at 14:06 +0800, hezjing wrote:
> Hi Prashant
> 
> Thanks for the WAR task description.
> 
> If I have a path-like structure called "base.path",
> 
>   <path id="base.path">
>   <fileset dir="lib">
>   <include name="**/*.jar"/>
>   </fileset>
>   </path>
> 
> How can I referencing "base.path" directly in <war> task or it's
> nested <lib> element?

WAR task specifies in the documentation that : 

"The nested lib element specifies a FileSet. All files included in this
fileset will end up in the WEB-INF/lib directory of the war file."

So try : 
<lib refid="base.path">

Actually if you are using modern IDE (like IDEA) to edit your build.xml
typing "<lib" should fire-up all possible options to auto-complete. 

Hope this helps.

> 
> 
> 
> 
> On 7/10/07, Prashant Reddy <pr...@pramati.com> wrote:
> > Take a look at 'war' task at :
> > http://ant.apache.org/manual/CoreTasks/war.html
> >
> > Examples given in this page should address your concern.
> >
> > On Tue, 2007-07-10 at 10:21 +0800, hezjing wrote:
> > > Hi
> > >
> > > I have a path structure containing a list of JARs, saved at the shared
> > > repository.
> > >
> > > How can I inlucde these JARs into WEB-INF/lib when creating a WAR
> > > file, without copying the JARs into local project directory?
> > >
> > >
> > --
> >
> > -Prashant
> >
> > Don't upload, just share : www.dekoh.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> 
> 
-- 

-Prashant

Don't upload, just share : www.dekoh.com


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


Re: Create WEB-INF/lib based on path-structure

Posted by Steve Loughran <st...@apache.org>.
hezjing wrote:
> Hi Prashant
> 
> Thanks for the WAR task description.
> 
> If I have a path-like structure called "base.path",
> 
>  <path id="base.path">
>  <fileset dir="lib">
>  <include name="**/*.jar"/>
>  </fileset>
>  </path>
> 


you should know that app servers will only add WEB-INF/lib/*.jar to 
their path, not **/*.jar.

I normally just copy everything I need to a single directory; you can 
use the <flatten> mapper to flatten directories in the process.

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Re: Create WEB-INF/lib based on path-structure

Posted by hezjing <he...@gmail.com>.
Hi Prashant

Thanks for the WAR task description.

If I have a path-like structure called "base.path",

  <path id="base.path">
  <fileset dir="lib">
  <include name="**/*.jar"/>
  </fileset>
  </path>

How can I referencing "base.path" directly in <war> task or it's
nested <lib> element?




On 7/10/07, Prashant Reddy <pr...@pramati.com> wrote:
> Take a look at 'war' task at :
> http://ant.apache.org/manual/CoreTasks/war.html
>
> Examples given in this page should address your concern.
>
> On Tue, 2007-07-10 at 10:21 +0800, hezjing wrote:
> > Hi
> >
> > I have a path structure containing a list of JARs, saved at the shared
> > repository.
> >
> > How can I inlucde these JARs into WEB-INF/lib when creating a WAR
> > file, without copying the JARs into local project directory?
> >
> >
> --
>
> -Prashant
>
> Don't upload, just share : www.dekoh.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 

Hez

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


Re: Create WEB-INF/lib based on path-structure

Posted by Prashant Reddy <pr...@pramati.com>.
Take a look at 'war' task at :
http://ant.apache.org/manual/CoreTasks/war.html

Examples given in this page should address your concern.

On Tue, 2007-07-10 at 10:21 +0800, hezjing wrote:
> Hi
> 
> I have a path structure containing a list of JARs, saved at the shared
> repository.
> 
> How can I inlucde these JARs into WEB-INF/lib when creating a WAR
> file, without copying the JARs into local project directory?
> 
> 
-- 

-Prashant

Don't upload, just share : www.dekoh.com


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


RE: Create WEB-INF/lib based on path-structure

Posted by Martin Gainty <mg...@hotmail.com>.
Yep that will package spurious jars into a new uber-war...BTW in maven you could use <dependency-management> to accomplish this objective
Glad to hear you got this problem solved..thanks for the info
Martin > Date: Wed, 13 Mar 2013 15:54:22 -0700
> From: sanjiv_thakor@yahoo.com
> To: user@ant.apache.org
> Subject: Re: Create WEB-INF/lib based on path-structure
> 
> i went through a bunch of posts and did not find the answer.  Finally i
> solved it as explained below.  my way is possibly a little verbose but it
> does the job.  SO my goal was to be able to include my libs(.jar files)
> which are in some third party dir referenced by $3rdParty-libs, into the
> WEB-INF/lib directory.  Also the structure of my 3rd-party-libs is:
>  /...../
>         -3rd-party-libs/
>              - cometd-2.4.3/ 
>                   - bunch of .jar files
>              - commons-lang3-3.1/
>                   - bunch of .jar files
>              - restlet-jee-2.1.2/
>                   - bunch of .jar files
> 
>      So in addition to getting all the required jar files under my war's
> WEB-INF/lib directory i did NOT want the directory structure of these jar
> files to be carried over 
>     i.e  i did NOT want  WEB-INF/lib/cometd-2.4.3/<someCometd>.jar
> i wanted it like: WEB-INF/lib/<someCometd>.jar
> 
> so the simple solution is to specify the war task's <lib> nested element
> multiple times.  Once per directory that you want to reference inside your
> 3rd-party-libs directory.
> 
> Here is my war target:
> ================
>     <target name="war" depends="compile">
>         <war destfile="dist/waisApp.war" webxml="WebContent/WEB-INF/web.xml"
> update="true">
>             <lib dir="${3rd-party-libs}/cometd-2.4.3/">
>                 <include name="*.jar"/>
>             </lib>
>         	<lib dir="${3rd-party-libs}/commons-lang3-3.1/">
>                 <include name="*.jar"/>
>             </lib>
>         	<lib dir="${3rd-party-libs}/restlet-jee-2.1.2/">
>                 <include name="*.jar"/>
>             </lib>
>             <fileset dir="WebContent"/>
>             <classes dir="build/classes"/>
>         </war>
>     </target>
> 
> 
> 
> --
> View this message in context: http://ant.1045680.n5.nabble.com/Create-WEB-INF-lib-based-on-path-structure-tp1350348p5713953.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
 		 	   		  

Re: Create WEB-INF/lib based on path-structure

Posted by sthakor <sa...@yahoo.com>.
i went through a bunch of posts and did not find the answer.  Finally i
solved it as explained below.  my way is possibly a little verbose but it
does the job.  SO my goal was to be able to include my libs(.jar files)
which are in some third party dir referenced by $3rdParty-libs, into the
WEB-INF/lib directory.  Also the structure of my 3rd-party-libs is:
 /...../
        -3rd-party-libs/
             - cometd-2.4.3/ 
                  - bunch of .jar files
             - commons-lang3-3.1/
                  - bunch of .jar files
             - restlet-jee-2.1.2/
                  - bunch of .jar files

     So in addition to getting all the required jar files under my war's
WEB-INF/lib directory i did NOT want the directory structure of these jar
files to be carried over 
    i.e  i did NOT want  WEB-INF/lib/cometd-2.4.3/<someCometd>.jar
i wanted it like: WEB-INF/lib/<someCometd>.jar

so the simple solution is to specify the war task's <lib> nested element
multiple times.  Once per directory that you want to reference inside your
3rd-party-libs directory.

Here is my war target:
================
    <target name="war" depends="compile">
        <war destfile="dist/waisApp.war" webxml="WebContent/WEB-INF/web.xml"
update="true">
            <lib dir="${3rd-party-libs}/cometd-2.4.3/">
                <include name="*.jar"/>
            </lib>
        	<lib dir="${3rd-party-libs}/commons-lang3-3.1/">
                <include name="*.jar"/>
            </lib>
        	<lib dir="${3rd-party-libs}/restlet-jee-2.1.2/">
                <include name="*.jar"/>
            </lib>
            <fileset dir="WebContent"/>
            <classes dir="build/classes"/>
        </war>
    </target>



--
View this message in context: http://ant.1045680.n5.nabble.com/Create-WEB-INF-lib-based-on-path-structure-tp1350348p5713953.html
Sent from the Ant - Users mailing list archive at Nabble.com.

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