From 33bc8da11841b4c56234262bd17649990f09d751 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 11 Jan 2002 14:59:40 +0000 Subject: [PATCH] Change the methods that try to locate JDK tools to work on AIX with IBM's JDK 1.2 as well. @todo refactor into a single method somewhere PR: 5541 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270667 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Javac.java | 23 +++++++++---- .../apache/tools/ant/taskdefs/Javadoc.java | 32 ++++++++++++------- .../tools/ant/types/CommandlineJava.java | 23 ++++++++++--- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index d867f55ec..5da35685a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2001 The Apache Software Foundation. All rights + * Copyright (c) 2000-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -680,14 +680,25 @@ public class Javac extends MatchingTask { // nothing for *nix. String extension = Os.isFamily("dos") ? ".exe" : ""; - // Look for java in the java.home/../bin directory. Unfortunately + File jExecutable = null; + + // On AIX using IBM's JDK 1.2 the javac executable is in + // the java.home/../../sh directory + if (Os.isName("aix")) { + jExecutable = new File(System.getProperty("java.home") + + "/../../sh/javac" + extension); + } + + if (jExecutable == null || !jExecutable.exists()) { + // Look for javac in the java.home/../bin directory. + jExecutable = new File(System.getProperty("java.home") + + "/../bin/javac" + extension); + } + + // Unfortunately // on Windows java.home doesn't always refer to the correct location, // so we need to fall back to assuming java is somewhere on the // PATH. - java.io.File jExecutable = - new java.io.File(System.getProperty("java.home") + - "/../bin/javac" + extension ); - if (jExecutable.exists() && !Os.isFamily("netware")) { return jExecutable.getAbsolutePath(); } else { diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 2d3dbeb9f..8acc80f7a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2001 The Apache Software Foundation. All rights + * Copyright (c) 2000-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -1161,19 +1161,29 @@ public class Javadoc extends Task { // nothing for *nix. String extension = Os.isFamily("dos") ? ".exe" : ""; - // Look for javadoc in the java.home/../bin directory. Unfortunately - // on Windows java.home doesn't always refer to the correct location, - // so we need to fall back to assuming javadoc is somewhere on the + File jdocExecutable = null; + + // On AIX using IBM's JDK 1.2 the javadoc executable is in + // the java.home/../sh directory + if (Os.isName("aix")) { + jdocExecutable = new File(System.getProperty("java.home") + + "/../sh/javadoc" + extension); + } + + if (jdocExecutable == null || !jdocExecutable.exists()) { + // Look for javadoc in the java.home/../bin directory. + jdocExecutable = new File(System.getProperty("java.home") + + "/../bin/javadoc" + extension); + } + + // Unfortunately + // on Windows java.home doesn't always refer to the correct location, + // so we need to fall back to assuming java is somewhere on the // PATH. - File jdocExecutable = new File( System.getProperty("java.home") + - "/../bin/javadoc" + extension ); - if (jdocExecutable.exists() && !Os.isFamily("netware")) - { + if (jdocExecutable.exists() && !Os.isFamily("netware")) { return jdocExecutable.getAbsolutePath(); - } - else - { + } else { if (!Os.isFamily("netware")) { log( "Unable to locate " + jdocExecutable.getAbsolutePath() + ". Using \"javadoc\" instead.", Project.MSG_VERBOSE ); diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index 5b00df8eb..7c5f7cfff 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2001 The Apache Software Foundation. All rights + * Copyright (c) 2000-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,6 +54,7 @@ package org.apache.tools.ant.types; +import java.io.File; import java.util.Properties; import java.util.Enumeration; import java.util.Vector; @@ -352,13 +353,25 @@ public class CommandlineJava implements Cloneable { // nothing for *nix. String extension = Os.isFamily("dos") ? ".exe" : ""; - // Look for java in the java.home/../bin directory. Unfortunately + File jExecutable = null; + + // On AIX using IBM's JDK 1.2 the java executable is in + // the java.home/../sh directory + if (Os.isName("aix")) { + jExecutable = new File(System.getProperty("java.home") + + "/../sh/java" + extension); + } + + if (jExecutable == null || !jExecutable.exists()) { + // Look for java in the java.home/../bin directory. + jExecutable = new File(System.getProperty("java.home") + + "/../bin/java" + extension); + } + + // Unfortunately // on Windows java.home doesn't always refer to the correct location, // so we need to fall back to assuming java is somewhere on the // PATH. - java.io.File jExecutable = - new java.io.File(System.getProperty("java.home") + - "/../bin/java" + extension ); if (jExecutable.exists() && !Os.isFamily("netware")) { // NetWare may have a "java" in that directory, but 99% of