You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Todd Chambery <tc...@hotmail.com> on 2002/01/17 22:56:22 UTC

dynamically assembled classpath

Hey all,

I'm trying to assemble a classpath based on whether or not a system is
capable of compiling for WebLogic or WebSphere:

 <target name  ="set.foo.classpath"
   description ="sets the foo classpath">
  <available file="${websphere.home}" type="dir"
property="websphere.home.present"/>
  <available file="${weblogic.home}" type="dir"
property="weblogic.home.present"/>
  <antcall target="set.foo.base.classpath"/>
  <antcall target="set.foo.weblogic.classpath"/>
  <antcall target="set.foo.websphere.classpath"/>
  <path id="ecore.classpath">
   <path refid="ecore.base.classpath"/>
   <path refid="ecore.was.classpath"/>
   <path refid="ecore.wl.classpath"/>
  </path>
 </target>
 <target name  ="set.foo.base.classpath"
   description ="set the foo base classpath">
  <path id="foo.base.classpath">
        <!-- some path stuff -->
  </path>
 </target>
 <target name  ="set.foo.websphere.classpath"
   if   ="websphere.home.present">
      <path id="foo.was.classpath">
        <!-- websphere classpath assembly -->
      </path>
 </target>
 <target name  ="set.foo.weblogic.classpath"
   if   ="weblogic.home.present">
  <path id="foo.wl.classpath">
        <!-- weblogic classpath assembly -->
  </path>
 </target>

but this don't work:

S:\FOO>ant init
Buildfile: build.xml
set.foo.classpath:
set.foo.base.classpath:
set.foo.weblogic.classpath:
set.foo.websphere.classpath:
BUILD FAILED
Reference foo.base.classpath not found.

Is there a way to make this work, or a better way I'm not thinking of?

Thanks,

Todd

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: dynamically assembled classpath

Posted by Nico Seessle <ni...@apache.org>.
----- Original Message -----
From: "Todd Chambery" <tc...@hotmail.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Monday, January 21, 2002 4:44 AM
Subject: Re: dynamically assembled classpath


> I'm feeling kind of dumb here, but I can't the desired results.  Given an
> ant.properties that has these vars:
>
> project.root=.
> weblogic.home=d:/programs/weblogic
> #websphere.home=d:/WebSphere/AppServer
>
> I tried assembling the classpath thusly:
>
> <path id="foo.classpath">

And somewhere before these lines is a property-definition I guess?

<property file="ant.properties"/>

And "ant -verbose" tells you it is reading this file?

>   <fileset dir="${weblogic.home}">
>       <patternset>
>            <include name="${weblogic.home}/lib/**/*.jar"
if="weblogic.home"/>

And you should remove ${weblogic.home}/ from your "include name", since
these names are resolved relative to the dir specified in fileset, so this
would result in trying to find
${weblogic.home}/${weblogic.home}/lib/**/*.jar which looks wrong.

Nico




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: dynamically assembled classpath

Posted by Todd Chambery <tc...@hotmail.com>.
I'm feeling kind of dumb here, but I can't the desired results.  Given an
ant.properties that has these vars:

project.root=.
weblogic.home=d:/programs/weblogic
#websphere.home=d:/WebSphere/AppServer

I tried assembling the classpath thusly:

<path id="foo.classpath">
  <!-- put all .jar/.zip files in the other.lib.dir into the
javac.classpath -->
  <fileset dir="${other.lib.dir}">
      <include name="**/*.jar"/>
      <include name="**/*.zip"/>
  </fileset>

  <pathelement path="${foo.build.dir}"/>

  <fileset dir="${weblogic.home}">
      <patternset>
           <include name="${weblogic.home}/lib/**/*.jar"
if="weblogic.home"/>
           <include name="${weblogic.home}/lib/**/*.zip"
if="weblogic.home"/>
           <include name="${weblogic.home}/classes/**/*.classes"
if="weblogic.home"/>
      </patternset>
  </fileset>
  <fileset dir="${websphere.home}">
      <patternset>
          <include name="${websphere.home}/lib/**/*.jar"
if="websphere.home"/>
          <include name="${websphere.home}/lib/**/*.zip"
if="websphere.home"/>
      </patternset>
  </fileset>
</path>

but on first use of the classpath, same problem:

compile.all:
    [javac] Compiling 529 source files to D:\projects\foo\classes
BUILD FAILED
D:\projects\foo\build.xml:117: D:\projects\foo\${websphere.home} not found.

I can't put a patternset into the path task, and the fileset doesn't have an
'if' attrib, so when the classpath gets used, it looks for ${websphere.home}
dir even when nothing is included.

I'll take any suggestions,

Todd



----- Original Message -----
From: "Erik Hatcher" <ja...@ehatchersolutions.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Thursday, January 17, 2002 10:17 PM
Subject: Re: dynamically assembled classpath


> How about using if/unless clauses on <include>/<exclude>'s within a
> <patternset>???
>
> See: http://jakarta.apache.org/ant/manual/CoreTypes/patternset.html
>
>
> ----- Original Message -----
> From: "Todd Chambery" <tc...@hotmail.com>
> To: "Ant Users List" <an...@jakarta.apache.org>
> Sent: Thursday, January 17, 2002 4:56 PM
> Subject: dynamically assembled classpath
>
>
> > Hey all,
> >
> > I'm trying to assemble a classpath based on whether or not a system is
> > capable of compiling for WebLogic or WebSphere:
> >
> >  <target name  ="set.foo.classpath"
> >    description ="sets the foo classpath">
> >   <available file="${websphere.home}" type="dir"
> > property="websphere.home.present"/>
> >   <available file="${weblogic.home}" type="dir"
> > property="weblogic.home.present"/>
> >   <antcall target="set.foo.base.classpath"/>
> >   <antcall target="set.foo.weblogic.classpath"/>
> >   <antcall target="set.foo.websphere.classpath"/>
> >   <path id="ecore.classpath">
> >    <path refid="ecore.base.classpath"/>
> >    <path refid="ecore.was.classpath"/>
> >    <path refid="ecore.wl.classpath"/>
> >   </path>
> >  </target>
> >  <target name  ="set.foo.base.classpath"
> >    description ="set the foo base classpath">
> >   <path id="foo.base.classpath">
> >         <!-- some path stuff -->
> >   </path>
> >  </target>
> >  <target name  ="set.foo.websphere.classpath"
> >    if   ="websphere.home.present">
> >       <path id="foo.was.classpath">
> >         <!-- websphere classpath assembly -->
> >       </path>
> >  </target>
> >  <target name  ="set.foo.weblogic.classpath"
> >    if   ="weblogic.home.present">
> >   <path id="foo.wl.classpath">
> >         <!-- weblogic classpath assembly -->
> >   </path>
> >  </target>
> >
> > but this don't work:
> >
> > S:\FOO>ant init
> > Buildfile: build.xml
> > set.foo.classpath:
> > set.foo.base.classpath:
> > set.foo.weblogic.classpath:
> > set.foo.websphere.classpath:
> > BUILD FAILED
> > Reference foo.base.classpath not found.
> >
> > Is there a way to make this work, or a better way I'm not thinking of?
> >
> > Thanks,
> >
> > Todd
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: dynamically assembled classpath

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
How about using if/unless clauses on <include>/<exclude>'s within a
<patternset>???

See: http://jakarta.apache.org/ant/manual/CoreTypes/patternset.html


----- Original Message -----
From: "Todd Chambery" <tc...@hotmail.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Thursday, January 17, 2002 4:56 PM
Subject: dynamically assembled classpath


> Hey all,
>
> I'm trying to assemble a classpath based on whether or not a system is
> capable of compiling for WebLogic or WebSphere:
>
>  <target name  ="set.foo.classpath"
>    description ="sets the foo classpath">
>   <available file="${websphere.home}" type="dir"
> property="websphere.home.present"/>
>   <available file="${weblogic.home}" type="dir"
> property="weblogic.home.present"/>
>   <antcall target="set.foo.base.classpath"/>
>   <antcall target="set.foo.weblogic.classpath"/>
>   <antcall target="set.foo.websphere.classpath"/>
>   <path id="ecore.classpath">
>    <path refid="ecore.base.classpath"/>
>    <path refid="ecore.was.classpath"/>
>    <path refid="ecore.wl.classpath"/>
>   </path>
>  </target>
>  <target name  ="set.foo.base.classpath"
>    description ="set the foo base classpath">
>   <path id="foo.base.classpath">
>         <!-- some path stuff -->
>   </path>
>  </target>
>  <target name  ="set.foo.websphere.classpath"
>    if   ="websphere.home.present">
>       <path id="foo.was.classpath">
>         <!-- websphere classpath assembly -->
>       </path>
>  </target>
>  <target name  ="set.foo.weblogic.classpath"
>    if   ="weblogic.home.present">
>   <path id="foo.wl.classpath">
>         <!-- weblogic classpath assembly -->
>   </path>
>  </target>
>
> but this don't work:
>
> S:\FOO>ant init
> Buildfile: build.xml
> set.foo.classpath:
> set.foo.base.classpath:
> set.foo.weblogic.classpath:
> set.foo.websphere.classpath:
> BUILD FAILED
> Reference foo.base.classpath not found.
>
> Is there a way to make this work, or a better way I'm not thinking of?
>
> Thanks,
>
> Todd
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>