ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Adiba <a.nico...@usa.net>
Subject Re: Specifying different compilers for Javac task?
Date Fri, 12 May 2000 00:50:22 GMT

    Hi,

    You choose the way your compiler is called with with the property
"build.compiler". JAVA_HOME is used to point to your jdk (if you use jikes it won't
be in your jdk). "build.compiler" has 3 hardcoded values which are: classic, jikes
and modern.
    So you can't really specify any compiler but you can choose between javac
1.1/1.2 style, javac 1.3 style or jikes (is found from the system path which means
there is directory in this path where jikes is).
    However for the first two you need tools.jar in your classpath (set
JAVA_HOME=e:\jdk1.2.2 and then set
classpath=lib/ant;lib/xml;%JAVA_HOME%/lib/tools.jar under windows before calling
ant).
    If you just want to switch from one jdk to another change your JAVA_HOME. In any
case JAVA_HOME is supposed to point to the directory where bin/, lib/, jre/, ... of
the jdk are. If you are confused by the classpath (we have all been through that)
try to play with it, when you will be tired making classpath errors you will
understand.
    If you want to use jikes in a build file try something like this: (sorry if you
are not working on windows ... but the idea is here)

build.bat:

set JIKES=e:\progra~1\jikes\
set PATH=%PATH%;%JIKES%
set JAVA_HOME=e:\jdk1.2.2
set
ANT_CLASSPATH=%CLASSPATH%..\..\lib\ant.jar;..\..\lib\xml.jar;%JAVA_HOME%\lib\tools.jar

%JAVA_HOME%\bin\java -classpath "%ANT_CLASSPATH%" org.apache.tools.ant.Main %1 %2 %3
%4 %5 %6 %7 %8 %9

build.xml:

    <project name="CompTest basedir=".">
        <target name="compile">
            <property name="build.compiler" value="jikes">
            <javac .... />
        <target/>
    <project />

    Hope it helps, if you still have questions take a look to the source code it's
simple to understand: src/main/org/apache/tools/ant/taskdefs/Javac.java. There are
some more answers embedded to your mail.


Nicolas.

---------------------------------------------------------------------------
Nicolas Adiba - a.nicolas@usa.net
graduate student, software engineering, network and distributed systems
Joseph Fourier University, Grenoble, France
---------------------------------------------------------------------------

Diane Holt wrote:

> Thanks for the pointer -- but maybe I should preface all my questions
> with: After having read the Ant user's manual several times, I still need
> to ask...
>
> (See why I apologized for being a bozo :)
>
> Thanks,
> Diane
>
> --- Christopher Elkins <celkins@scardini.com> wrote:
> > > I'm not sure I understand how to specify which java compiler to use.
> > Is it
> > > based on what JAVA_HOME is set to in the environment? The user's
> > manual
> > > mentions a build.compiler property -- is that where you'd specify it?

yes

>
> > If
> > > it is, where would you do that

anywhere such as the init target or in your compile target

> , and what would the specification be --
> > a
> > > directory path to where all the bin, lib, etc. directories for that
> > jdk
> > > live?

build.compiler has only 3 values: classic, standard and jikes. You need to
understand that javac is in the java library tools.jar in all jdk (need to be in
your classpath), but jikes is an external program (need to be in your path).

> And where does JAVA_HOME come into it?

JAVA_HOME point to the directory where is installed your jdk. It's just a convention
and is not used directly by ant (it's an assumption, I'm not sure).

>
> > >
> > > (Sorry for being such a bozo about this stuff -- I'm signed up for a
> > java
> > > class in a couple of weeks, so hopefully I'll be a little less so
> > after
> > > that.)
> > >
> > Don't apologize for asking questions - everyone was a beginnner at
> > first!
> >
> > However, you might want to read the FAQ
> >
> <http://jakarta.apache.org/jyve-faq/Turbine/screen/DisplayQuestionAnswer/action/
> > SetAll/project_id/2/faq_id/16/topic_id/72/question_id/339>, where I've
> > already
> > answered this question. ;-)
> >
> > > Thanks,
> > > Diane
> > >
> > > =====
> > > (holtdl@yahoo.com)
> > >
> >
> > --
> > Christopher Elkins
> >
>
> =====
> (holtdl@yahoo.com)
>
> __________________________________________________
> Do You Yahoo!?
> Send instant messages & get email alerts with Yahoo! Messenger.
> http://im.yahoo.com/


Mime
View raw message