You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Gordon Tyler <go...@sitraka.com> on 2002/04/19 00:17:26 UTC

Ant 1.4.1: Using javac fork=true and changing java.home

Running Ant1.4.1 with JDK 1.3.1_03.

I'm trying to build parts of my project with JDK 1.3 and other parts with
1.4. The 1.4 compilation targets look like this:

<target name="compile-java-1.4">
    <antcall target="compile-java-1.4-impl">
        <param name="java.home" value="${java14.home}"/>
    </antcall>
</target>

<target name="compile-java-1.4-impl">
    <javac classpathref="alto.classpath"
        debug="yes"
        deprecation="yes"
        destdir="${build}"
        srcdir="${src}"
        fork="true"
        target="1.4"
        source="1.4">
        <include name="${alto.package}/client/**/*.java"/>
        <include name="${alto.package}/commonui/**/*.java"/>
        <include name="${alto.package}/nexus/**/*.java"/>
        <include name="${alto.package}/workstation/**/*.java"/>
        <exclude name="${alto.test.dir}/*.java"/>
    </javac>
</target>

However, it seems that <javac fork=true> doesn't use the java.home property
to execute javac. It appears to execute whatever javac it finds on the PATH
which happens to be JDK 1.3. Is it supposed to use java.home to find the
javac executable or am I misinterpreting the docs?

Thanks,
Gordon

---
Sitraka -- the Java advantage
http://www.sitraka.com/


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


Re: Ant 1.4.1: Using javac fork=true and changing java.home

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 19 Apr 2002, Gordon Tyler <go...@sitraka.com> wrote:

> Hmm... When is Ant 1.5 slated for release?

The first beta release is scheduled for the beginning of May.

Stefan

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


Re: Ant 1.4.1: Using javac fork=true and changing java.home

Posted by Gordon Tyler <go...@sitraka.com>.
----- Original Message -----
From: "Stefan Bodewig" <bo...@apache.org>


> On Thu, 18 Apr 2002, Gordon Tyler <go...@sitraka.com> wrote:

> Ant 1.5alpha has a new attribute in <javac> that lets you explicitly
> point Ant to the compiler you want to use.

Hmm... When is Ant 1.5 slated for release?

> suggests or set includejavaruntime and includeantruntime to false, add
> tools.jar of JDK 1.4.1 to <javac>'s <classpath> and don't use fork.

Interesting idea. I'll try that as well. It would be preferable since it
doesn't fork.

Thanks for the suggestions.

Ciao,
Gordon



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


Re: Ant 1.4.1: Using javac fork=true and changing java.home

Posted by Simon Curran <s....@aepona.com>.
Yeah, I had this problem the other day and these guys helped me to resolve it...

This is the solution that they came up with.  I was compiling all my java source with java 1.3 but wanted to build my javadocs using
java 1.4....

<target name="buildJavadoc" depends="initCommon" >

        <!-- Build the javadoc in a seperate ant process so that we can use version 1.4 of the javadoc utility -->
        <exec executable="ant">
            <arg line="-buildfile ${ant.file} javadocCreate"/>
            <env key="JAVA_HOME" value="${java_home1.4}"/>
        </exec>

        <echo message="Reverting back to Java ${ant.java.version} for remainder of build..."/>

</target>

<target name="javadocCreate" depends="retrieveFileNamesForJavadoc" >

        <javadoc sourcepath="${pcp_source_dir}:${parlay_src}:${parlay_rel4_src}"
            classpath="${sdk_jar_file}:${corba_classpath_stuff}"
            packageList="${working_directory}/tmpJavadocInput2"
            ....
            ....


Simon.

Stefan Bodewig wrote:

> On Thu, 18 Apr 2002, Gordon Tyler <go...@sitraka.com> wrote:
>
> > However, it seems that <javac fork=true> doesn't use the java.home
> > property to execute javac.
>
> Correct.
>
> Ant 1.5alpha has a new attribute in <javac> that lets you explicitly
> point Ant to the compiler you want to use.
>
> For 1.4.1 you can either <exec> a new instance of Ant like Diane
> suggests or set includejavaruntime and includeantruntime to false, add
> tools.jar of JDK 1.4.1 to <javac>'s <classpath> and don't use fork.
>
> Stefan
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--

***************************************************************
* Simon Curran              * Email : simon.curran@aepona.com *
* Software Engineer         * WWW   : www.aepona.com          *
* Aepona Ltd.               * Phone : +44 (0)28 9027 5231     *
* Interpoint Building,      * Fax   : +44 (0)28 9026 9111     *
* 20-24 York Street,        *                                 *
* Belfast. BT15 1AQ.        *                                 *
* N. Ireland.               *                                 *
***************************************************************



Re: Ant 1.4.1: Using javac fork=true and changing java.home

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 18 Apr 2002, Gordon Tyler <go...@sitraka.com> wrote:

> However, it seems that <javac fork=true> doesn't use the java.home
> property to execute javac.

Correct.

Ant 1.5alpha has a new attribute in <javac> that lets you explicitly
point Ant to the compiler you want to use.

For 1.4.1 you can either <exec> a new instance of Ant like Diane
suggests or set includejavaruntime and includeantruntime to false, add
tools.jar of JDK 1.4.1 to <javac>'s <classpath> and don't use fork.

Stefan

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


RE: Ant 1.4.1: Using javac fork=true and changing java.home

Posted by "John W. Warner" <jw...@ccs.nrl.navy.mil>.
I don't know if this will help you or not.
I had JWSDP ea2 which has ant 1.4.1 in it and I originally installed it
with the Sun JDK 1.3.1_02 and had stuff working fine. I changed to JDK
1.4.0 and I got this really weird error saying;
JAVA_HOME not set properly. 
Unable to execute command '-Dlog:Jakarta.apache.log...' 
So, I uninstalled JWSDP and re-installed it so that it would formally
recognize the 1.4.0 jdk. So now the whole thing works again. 

Anyway, the reason why I mention this is I wonder what would happen if
you tried the JWSDP letting it link to JDK 1.4.0 and then backward
calling your 1.3.1_03 JDK.. Kinda a reverse of what you're doing but in
this case letting JDK 1.4.0 have the upper hand.

Good luck on your issue,
- John 

-----Original Message-----
From: Gordon Tyler [mailto:gordon.tyler@sitraka.com] 
Sent: Thursday, April 18, 2002 06:17 PM
To: Ant User List
Subject: Ant 1.4.1: Using javac fork=true and changing java.home

Running Ant1.4.1 with JDK 1.3.1_03.

I'm trying to build parts of my project with JDK 1.3 and other parts
with
1.4. The 1.4 compilation targets look like this:

<target name="compile-java-1.4">
    <antcall target="compile-java-1.4-impl">
        <param name="java.home" value="${java14.home}"/>
    </antcall>
</target>

<target name="compile-java-1.4-impl">
    <javac classpathref="alto.classpath"
        debug="yes"
        deprecation="yes"
        destdir="${build}"
        srcdir="${src}"
        fork="true"
        target="1.4"
        source="1.4">
        <include name="${alto.package}/client/**/*.java"/>
        <include name="${alto.package}/commonui/**/*.java"/>
        <include name="${alto.package}/nexus/**/*.java"/>
        <include name="${alto.package}/workstation/**/*.java"/>
        <exclude name="${alto.test.dir}/*.java"/>
    </javac>
</target>

However, it seems that <javac fork=true> doesn't use the java.home
property
to execute javac. It appears to execute whatever javac it finds on the
PATH
which happens to be JDK 1.3. Is it supposed to use java.home to find the
javac executable or am I misinterpreting the docs?

Thanks,
Gordon

---
Sitraka -- the Java advantage
http://www.sitraka.com/


--
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: Ant 1.4.1: Using javac fork=true and changing java.home

Posted by Gordon Tyler <go...@sitraka.com>.
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>


> --- Gordon Tyler <go...@sitraka.com> wrote:
> > Running Ant1.4.1 with JDK 1.3.1_03.
> >
> > I'm trying to build parts of my project with JDK 1.3 and other parts
> > with 1.4.
>
> I thought the agreed upon approach (when this came up the other day) was
> to <exec> 'ant', passing JAVA_HOME via an <env>.

I tried this but it didn't work. I suspect it is because our main build
machine (and developers' machines) is Windows 2000 and the Windows API
CreateProcess call (as used by exec) doesn't know how to execute 'ant.cmd'.
Yes, I know could use 'cmd.exe' but that seems like too much of a hack. Also
this solution breaks the build into separate Ant executions which could have
weird effects on the build listeners that we use for mailing build results.

What I ended up doing was duplicating JavacExternal in our in-house Ant
addon classes and changing it to use java.home and the modern command line.
Then I added an additional param to the antcall, setting build.compiler to
use this class. This works well enough for the moment.

Ciao,
Gordon



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


Re: Ant 1.4.1: Using javac fork=true and changing java.home

Posted by Diane Holt <ho...@yahoo.com>.
--- Gordon Tyler <go...@sitraka.com> wrote:
> Running Ant1.4.1 with JDK 1.3.1_03.
> 
> I'm trying to build parts of my project with JDK 1.3 and other parts
> with 1.4.

I thought the agreed upon approach (when this came up the other day) was
to <exec> 'ant', passing JAVA_HOME via an <env>.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

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