You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Siri Nivasam <si...@hotmail.com> on 2003/12/15 17:59:06 UTC

select properties file

I have two different properties files which I use when I build on windows 
and unix machines.

How do I tell ant to use the appropriate file depending on the os.name?

Any help is appreciated.

Thanks
Siri.

_________________________________________________________________
Our best dial-up offer is back.  Get MSN Dial-up Internet Service for 6 
months @ $9.95/month now! http://join.msn.com/?page=dept/dialup


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


Can I append classpath variable through multiple targets?

Posted by ba...@goodconsultants.com.
When executing this i have the following output... Is that mean the path has 
not bee appended?

classpath-general:
     [echo] classpath-general in here!
Overriding previous definition of reference to compile.classpath

classpath-tomcat:
     [echo] classpath-tomcat: CATALINA_HOME is /home/barry/thirdparty/tomcat
Overriding previous definition of reference to compile.classpath



Thanks

Barry

Quoting barry@goodconsultants.com:

> Hi all,
> 
> Can I append classpath variable through multiple targets? Please check the 
> following codes...
> 
> <target name="classpath-general">
> 
>         <echo message="classpath-general in here!"/>
> 
>         <path id="compile.classpath">
> 
>                 <pathelement location="${j2eeBase}/lib/j2ee.jar"/>
> 
>         </path>
> 
> </target>
> 
> 
> <target name="classpath-tomcat" >
> 
>         <echo message="classpath-tomcat: CATALINA_HOME is 
> ${system.CATALINA_HOME}"/>
> 
>         <path id="compile.classpath">
>         <pathelement location="${catalina.home}/common/classes"/>
>         <fileset dir="${catalina.home}/common/endorsed">
>                 <include name="*.jar"/>
>         </fileset>
> 
>         <fileset dir="${catalina.home}/common/lib">
>                 <include name="*.jar"/>
>         </fileset>
> 
>         <pathelement location="${catalina.home}/shared/classes"/>
>         <fileset dir="${catalina.home}/shared/lib">
>                 <include name="*.jar"/>
>         </fileset>
> 
>         </path>
> 
> 
> </target>
> 
> 
> 
> ---------------------------------------------------------------------
> 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


Can I append classpath variable through multiple targets?

Posted by ba...@goodconsultants.com.
Hi all,

Can I append classpath variable through multiple targets? Please check the 
following codes...

<target name="classpath-general">

        <echo message="classpath-general in here!"/>

        <path id="compile.classpath">

                <pathelement location="${j2eeBase}/lib/j2ee.jar"/>

        </path>

</target>


<target name="classpath-tomcat" >

        <echo message="classpath-tomcat: CATALINA_HOME is 
${system.CATALINA_HOME}"/>

        <path id="compile.classpath">
        <pathelement location="${catalina.home}/common/classes"/>
        <fileset dir="${catalina.home}/common/endorsed">
                <include name="*.jar"/>
        </fileset>

        <fileset dir="${catalina.home}/common/lib">
                <include name="*.jar"/>
        </fileset>

        <pathelement location="${catalina.home}/shared/classes"/>
        <fileset dir="${catalina.home}/shared/lib">
                <include name="*.jar"/>
        </fileset>

        </path>


</target>



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


Re: multiple selection of classpath??

Posted by ba...@goodconsultants.com.
Antonine,

What should be the content of the init.tomcat? I think I am trying to do the 
same thing like you said but the classpath defined in init.tomcat does not 
seem to recongised in other parts of build.xml... Please see the other email 
for detail codes.

Thanks

BArry

Quoting Antoine Lévy-Lambert <an...@antbuild.com>:

> barry@goodconsultants.com wrote:
> 
> >All,
> >
> >1. How can I select multiple classpath? I would like to be able NOT to
> define 
> >CATALINA_HOME for tomcat if not compiling things for tomcat, and just use 
> >J2EE... 
> >
> >  
> >
> the normal ant way is then to define one different init target for each 
> variant of your build or deployment.
> 
> <target name="init.tomcat" if="on.tomcat">
>    some action here
> </target>
> <target name="init.j2ee" depends="on.j2ee">
>    some action here
> </target>
> <target name="build" depends="init.tomcat,init.j2ee">
>   some action here
> </target>
> 
> then if you do :
> 
> ant -D"on.tomcat=true" build
> 
> you are going to execute the init.tomcat and build targets. The 
> init.j2ee target will then not be executed, because on.j2ee is not defined.
> 
> ant -D"on.j2ee=true" build
> 
> will make you execute init.j2ee and build
> 
> 
> >2. Can I define the followings in properties file?
> >
> ><path id="compile.classpath">
> >
> >        <pathelement location="${catalina.home}/common/classes"/>
> >        <fileset dir="${catalina.home}/common/endorsed">
> >                <include name="*.jar"/>
> >        </fileset>
> >        <fileset dir="${catalina.home}/common/lib">
> >                <include name="*.jar"/>
> >        </fileset>
> >
> >        <pathelement location="${catalina.home}/shared/classes"/>
> >        <fileset dir="${catalina.home}/shared/lib">
> >                <include name="*.jar"/>
> >        </fileset>
> >
> >        </path>
> >
> >
> >
> >Thanks
> >
> >Barry
> >
> >
> >
> >
> >  
> >
> the build file snippet above is too complicated for a property file. In 
> ant 1.6, you can save this snippet as a separate xml file and use the 
> <import/> task to use this in several other build files.
> 
> Hopes this helps,
> 
> Antoine
> 
> Antoine
> 
> ---------------------------------------------------------------------
> 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: multiple selection of classpath??

Posted by Antoine Lévy-Lambert <an...@antbuild.com>.
barry@goodconsultants.com wrote:

>All,
>
>1. How can I select multiple classpath? I would like to be able NOT to define 
>CATALINA_HOME for tomcat if not compiling things for tomcat, and just use 
>J2EE... 
>
>  
>
the normal ant way is then to define one different init target for each 
variant of your build or deployment.

<target name="init.tomcat" if="on.tomcat">
   some action here
</target>
<target name="init.j2ee" depends="on.j2ee">
   some action here
</target>
<target name="build" depends="init.tomcat,init.j2ee">
  some action here
</target>

then if you do :

ant -D"on.tomcat=true" build

you are going to execute the init.tomcat and build targets. The 
init.j2ee target will then not be executed, because on.j2ee is not defined.

ant -D"on.j2ee=true" build

will make you execute init.j2ee and build


>2. Can I define the followings in properties file?
>
><path id="compile.classpath">
>
>        <pathelement location="${catalina.home}/common/classes"/>
>        <fileset dir="${catalina.home}/common/endorsed">
>                <include name="*.jar"/>
>        </fileset>
>        <fileset dir="${catalina.home}/common/lib">
>                <include name="*.jar"/>
>        </fileset>
>
>        <pathelement location="${catalina.home}/shared/classes"/>
>        <fileset dir="${catalina.home}/shared/lib">
>                <include name="*.jar"/>
>        </fileset>
>
>        </path>
>
>
>
>Thanks
>
>Barry
>
>
>
>
>  
>
the build file snippet above is too complicated for a property file. In 
ant 1.6, you can save this snippet as a separate xml file and use the 
<import/> task to use this in several other build files.

Hopes this helps,

Antoine

Antoine

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


multiple selection of classpath??

Posted by ba...@goodconsultants.com.
All,

1. How can I select multiple classpath? I would like to be able NOT to define 
CATALINA_HOME for tomcat if not compiling things for tomcat, and just use 
J2EE... 

2. Can I define the followings in properties file?

<path id="compile.classpath">

        <pathelement location="${catalina.home}/common/classes"/>
        <fileset dir="${catalina.home}/common/endorsed">
                <include name="*.jar"/>
        </fileset>
        <fileset dir="${catalina.home}/common/lib">
                <include name="*.jar"/>
        </fileset>

        <pathelement location="${catalina.home}/shared/classes"/>
        <fileset dir="${catalina.home}/shared/lib">
                <include name="*.jar"/>
        </fileset>

        </path>



Thanks

Barry


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


Re: How can I select different classpath for building different apps?

Posted by ba...@goodconsultants.com.
Antoine,

Thanks for replying... It doesnt seem to work. Would you please tell me what i 
did wrong? Here is the code:

TARGET:

<target name="classpath-tomcat">

        <echo message="classpath-tomcat: CATALINA_HOME is 
${system.CATALINA_HOME}"/>

        <path id="compile.classpath">
        <pathelement location="${catalina.home}/common/classes"/>
        <fileset dir="${catalina.home}/common/endorsed">
                <include name="*.jar"/>
        </fileset>

        <fileset dir="${catalina.home}/common/lib">
                <include name="*.jar"/>
        </fileset>

        <pathelement location="${catalina.home}/shared/classes"/>
        <fileset dir="${catalina.home}/shared/lib">
                <include name="*.jar"/>
        </fileset>

        </path>


</target>


CALLING:

<target name="tomcat" if="system.CATALINA_HOME">

        <echo message="CATALINA_HOME is: ${system.CATALINA_HOME}"/>
        <antcall target="clean"/>
        <antcall target="init"/>
        <antcall target="classpath-tomcat"/>
        <antcall target="compile-newserver"/>
        <antcall target="dist-tomcat"/>
        <antcall target="deploy-tomcat"/>

</target>


JAVAC:

<target name="compile-newserver">

        <echo message="SOURCE DIRECTORY: ${src.home}"/>
        <echo message="TARGET DIRECTORY: ${build.home}"/>

        <!-- Compile Java classes as necessary -->
        <mkdir dir="${build.home}/WEB-INF/classes"/>
        <javac classpathref="compile.classpath"
                srcdir="${src.home}"
                destdir="${build.home}/WEB-INF/classes"
                debug="${compile.debug}"
                deprecation="${compile.deprecation}"
                optimize="${compile.optimize}"
                excludes="java/sandbox/**">
                <classpath refid="compile.classpath"/>
        </javac>

        <!-- Copy application resources -->
        <copy  todir="${build.home}/WEB-INF/classes">
                <fileset dir="${src.home}" excludes="**/*.java"/>
        </copy>
        <echo message="Completed."/>

</target>

ERROR:

BUILD FAILED
file:/home/barry/workarea/src/server/build.xml:245: Reference 
compile.classpath not found.

Quoting Antoine Lévy-Lambert <an...@antbuild.com>:

> barry@goodconsultants.com wrote:
> 
> >All,
> >
> >In one single build.xml, how can I select different set of classpaths? for 
> >Tomcat and for other apps?
> >
> >I try to do the followings:
> >
> ><target name="tomcat" if="system.CATALINA_HOME">
> >
> >        <antcall target="clean"/>
> >        <antcall target="init-tomcat"/>
> >        <antcall target="compile-newserver"/>
> >        <antcall target="dist-tomcat"/>
> >        <antcall target="deploy-tomcat"/>
> >
> ></target>
> >
> >In the init-tomcat target, I have the followings:
> >
> ><target name="init-tomcat">
> >
> >        <echo message="CATALINA_HOME is ${system.CATALINA_HOME}"/>
> >
> >        <path id="compile.classpath">
> >
> >        <pathelement location="${catalina.home}/common/classes"/>
> >        <fileset dir="${catalina.home}/common/endorsed">
> >                <include name="*.jar"/>
> >        </fileset>
> >        <fileset dir="${catalina.home}/common/lib">
> >                <include name="*.jar"/>
> >        </fileset>
> >
> >        <pathelement location="${catalina.home}/shared/classes"/>
> >        <fileset dir="${catalina.home}/shared/lib">
> >                <include name="*.jar"/>
> >        </fileset>
> >
> >        </path>
> >
> ></target>
> >
> >Unfortunately, it does not work setting classpath like this... Any advice? 
> >
> >Thanks
> >
> >Barry
> >
> >
> >  
> >
> ur target above init-tomcat creates a piece of data with id 
> "compile.classpath". But then you need to reference your classpath, for 
> instance in <javac>
> 
> <javac classpathref="compile.classpath" ...>
> <!-- other nested elements -->
> </javac>
> 
> will work.
> 
> Antoine
> 
> ---------------------------------------------------------------------
> 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: How can I select different classpath for building different apps?

Posted by Antoine Lévy-Lambert <an...@antbuild.com>.
barry@goodconsultants.com wrote:

>All,
>
>In one single build.xml, how can I select different set of classpaths? for 
>Tomcat and for other apps?
>
>I try to do the followings:
>
><target name="tomcat" if="system.CATALINA_HOME">
>
>        <antcall target="clean"/>
>        <antcall target="init-tomcat"/>
>        <antcall target="compile-newserver"/>
>        <antcall target="dist-tomcat"/>
>        <antcall target="deploy-tomcat"/>
>
></target>
>
>In the init-tomcat target, I have the followings:
>
><target name="init-tomcat">
>
>        <echo message="CATALINA_HOME is ${system.CATALINA_HOME}"/>
>
>        <path id="compile.classpath">
>
>        <pathelement location="${catalina.home}/common/classes"/>
>        <fileset dir="${catalina.home}/common/endorsed">
>                <include name="*.jar"/>
>        </fileset>
>        <fileset dir="${catalina.home}/common/lib">
>                <include name="*.jar"/>
>        </fileset>
>
>        <pathelement location="${catalina.home}/shared/classes"/>
>        <fileset dir="${catalina.home}/shared/lib">
>                <include name="*.jar"/>
>        </fileset>
>
>        </path>
>
></target>
>
>Unfortunately, it does not work setting classpath like this... Any advice? 
>
>Thanks
>
>Barry
>
>
>  
>
ur target above init-tomcat creates a piece of data with id 
"compile.classpath". But then you need to reference your classpath, for 
instance in <javac>

<javac classpathref="compile.classpath" ...>
<!-- other nested elements -->
</javac>

will work.

Antoine

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


How can I select different classpath for building different apps?

Posted by ba...@goodconsultants.com.
All,

In one single build.xml, how can I select different set of classpaths? for 
Tomcat and for other apps?

I try to do the followings:

<target name="tomcat" if="system.CATALINA_HOME">

        <antcall target="clean"/>
        <antcall target="init-tomcat"/>
        <antcall target="compile-newserver"/>
        <antcall target="dist-tomcat"/>
        <antcall target="deploy-tomcat"/>

</target>

In the init-tomcat target, I have the followings:

<target name="init-tomcat">

        <echo message="CATALINA_HOME is ${system.CATALINA_HOME}"/>

        <path id="compile.classpath">

        <pathelement location="${catalina.home}/common/classes"/>
        <fileset dir="${catalina.home}/common/endorsed">
                <include name="*.jar"/>
        </fileset>
        <fileset dir="${catalina.home}/common/lib">
                <include name="*.jar"/>
        </fileset>

        <pathelement location="${catalina.home}/shared/classes"/>
        <fileset dir="${catalina.home}/shared/lib">
                <include name="*.jar"/>
        </fileset>

        </path>

</target>

Unfortunately, it does not work setting classpath like this... Any advice? 

Thanks

Barry


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