ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r421585 - in /ant/core/trunk/src/main/org/apache/tools/ant: taskdefs/compilers/CompilerAdapterFactory.java taskdefs/compilers/Javac12.java util/JavaEnvUtils.java
Date Thu, 13 Jul 2006 11:03:33 GMT
Author: stevel
Date: Thu Jul 13 04:03:32 2006
New Revision: 421585

URL: http://svn.apache.org/viewvc?rev=421585&view=rev
Log:
Add extra diags on the error message by printing out java.home

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java?rev=421585&r1=421584&r2=421585&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
Thu Jul 13 04:03:32 2006
@@ -110,7 +110,10 @@
                                                  + " is not on the "
                                                  + "classpath.\n"
                                                  + "Perhaps JAVA_HOME does not"
-                                                 + " point to the JDK");
+                                                 + " point to the JDK.\n"
+                                + "It is currently set to \""
+                                + JavaEnvUtils.getJavaHome()
+                                + "\"");
                     }
                 }
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java?rev=421585&r1=421584&r2=421585&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java Thu Jul 13
04:03:32 2006
@@ -23,6 +23,8 @@
 import java.lang.reflect.Method;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.util.JavaEnvUtils;
+import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.taskdefs.LogOutputStream;
 import org.apache.tools.ant.types.Commandline;
 
@@ -34,6 +36,7 @@
  * @since Ant 1.3
  */
 public class Javac12 extends DefaultCompilerAdapter {
+    protected static final String CLASSIC_COMPILER_CLASSNAME = "sun.tools.javac.Main";
 
     /**
      * Run the compilation.
@@ -48,7 +51,7 @@
         try {
             // Create an instance of the compiler, redirecting output to
             // the project log
-            Class c = Class.forName("sun.tools.javac.Main");
+            Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME);
             Constructor cons =
                 c.getConstructor(new Class[] {OutputStream.class,
                                               String.class});
@@ -63,11 +66,15 @@
                                         new Object[] {cmd.getArguments()});
             return ok.booleanValue();
         } catch (ClassNotFoundException ex) {
-            throw new BuildException("Cannot use classic compiler, as it is "
-                                     + "not available.  A common solution is "
-                                     + "to set the environment variable"
-                                     + " JAVA_HOME to your jdk directory.",
-                                     location);
+            throw new BuildException("Cannot use classic compiler , as it is "
+                                        + "not available. \n"
+                                        + " A common solution is "
+                                        + "to set the environment variable"
+                                        + " JAVA_HOME to your jdk directory.\n"
+                                        + "It is currently set to \""
+                                        + JavaEnvUtils.getJavaHome()
+                                        + "\"",
+                                        location);
         } catch (Exception ex) {
             if (ex instanceof BuildException) {
                 throw (BuildException) ex;
@@ -76,12 +83,7 @@
                                          ex, location);
             }
         } finally {
-            try {
-                logstr.close();
-            } catch (IOException e) {
-                // plain impossible
-                throw new BuildException(e);
-            }
+            FileUtils.close(logstr);
         }
     }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java?rev=421585&r1=421584&r2=421585&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java Thu Jul 13 04:03:32
2006
@@ -414,4 +414,12 @@
         }
         return script;
     }
+
+    /**
+     * Return the value of ${java.home}
+     * @return the java home value.
+     */
+    public static String getJavaHome() {
+        return JAVA_HOME;
+    }
 }



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


Mime
View raw message