You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Jason van Zyl <jv...@periapt.com> on 2000/11/18 00:21:30 UTC

Passing classpath into a subproject?

Hi,

Is there any way to pass on classpath information to
a subproject? In the build file below is it possible
to pass the path information into the <ant> task? Is
there a way to have a global classpath without setting
the classpath in a .bat|.sh script?

<?xml version="1.0"?>

<!-- Build file for application -->
<project name="newapp" default="compile" basedir=".">

    [snip]
    
    <!-- Build classpath -->
    <path id="classpath">
        <fileset dir="../../../../lib">
	        <include name="**/*.jar"/>
        </fileset>
        <fileset dir="../lib">
	        <include name="**/*.jar"/>
        </fileset>
    </path>

    <!-- =================================================================== -->
    <!-- Compiles the source directory                                       -->
    <!-- =================================================================== -->  
    <target name="compile">
        
        <ant antfile="torque.xml" dir="torque"/>
        
        <javac srcdir="${src.dir}"
            destdir="${build.dest}"
            debug="${debug}"
            deprecation="${deprecation}"
            optimize="${optimize}">
            
            <classpath refid="classpath"/>

        </javac>
    </target>
</project>








-- 
jvz.

Jason van Zyl
jvanzyl@periapt.com


Re: Passing classpath into a subproject?

Posted by Jason van Zyl <jv...@periapt.com>.
On 20 Nov 2000, Stefan Bodewig wrote:

> Jason van Zyl <jv...@periapt.com> wrote:
> 
> > That's a start! It will certainly help if <taskdef> takes
> > a classpath. Is the following possible:
> > 
> > <taskdef 
> >   name="torque"
> >   class="org.apache.turbine.torque.ant.VTorqueTask"/>
> >   <classpath>
> >     <pathelement path="${class.path.set.in.parent.project}"/>
> >   </classpath>
> > </taskdef>
> 
> It is (you could have tried of course 8-). This is if
> class.path.set.in.parent.project is the name of a property, not a
> reference id.

I didn't know that I could set a property with with a path
as you previously described, or I would have! :-) Thanks
for the tip, much appreciated!

-- 
jvz.

Jason van Zyl
jvanzyl@periapt.com


Re: Passing classpath into a subproject?

Posted by Stefan Bodewig <bo...@apache.org>.
Jason van Zyl <jv...@periapt.com> wrote:

> That's a start! It will certainly help if <taskdef> takes
> a classpath. Is the following possible:
> 
> <taskdef 
>   name="torque"
>   class="org.apache.turbine.torque.ant.VTorqueTask"/>
>   <classpath>
>     <pathelement path="${class.path.set.in.parent.project}"/>
>   </classpath>
> </taskdef>

It is (you could have tried of course 8-). This is if
class.path.set.in.parent.project is the name of a property, not a
reference id.

Stefan

Re: Passing classpath into a subproject?

Posted by Jason van Zyl <jv...@periapt.com>.
On 20 Nov 2000, Stefan Bodewig wrote:

> Jason van Zyl <jv...@periapt.com> wrote:
> 
> > Is there any way to pass on classpath information to
> > a subproject?
> 
> Currently, all you can do is convert the <path> to a property
> (<property name="my.path" refid="classpath"/>) and recreate a <path> in
> your subproject (<path id="classpath" path="${my.path}" />) as
> references are not inherited by subprojects.

That's a start! It will certainly help if <taskdef> takes
a classpath. Is the following possible:

<taskdef 
  name="torque"
  class="org.apache.turbine.torque.ant.VTorqueTask"/>
  <classpath>
    <pathelement path="${class.path.set.in.parent.project}"/>
  </classpath>
</taskdef>
   
This would be fine if possible. I would rather do this then have
to build up the classpath in the .bat|.sh scripts

> > Is there a way to have a global classpath without setting the
> > classpath in a .bat|.sh script?
> 
> Don't think so, as the CLASSPATH would need to be set by the time Ant
> starts parsing your build file. Maybe I'm just misunderstanding what
> you are asking for.

I think you're right on :-)

-- 
jvz.

Jason van Zyl
jvanzyl@periapt.com


Re: Passing classpath into a subproject?

Posted by Stefan Bodewig <bo...@apache.org>.
Jason van Zyl <jv...@periapt.com> wrote:

> Is there any way to pass on classpath information to
> a subproject?

Currently, all you can do is convert the <path> to a property
(<property name="my.path" refid="classpath"/>) and recreate a <path> in
your subproject (<path id="classpath" path="${my.path}" />) as
references are not inherited by subprojects.

> Is there a way to have a global classpath without setting the
> classpath in a .bat|.sh script?

Don't think so, as the CLASSPATH would need to be set by the time Ant
starts parsing your build file. Maybe I'm just misunderstanding what
you are asking for.

Stefan