You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@apache.org on 2006/08/23 01:07:49 UTC

svn commit: r433794 - /ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java

Author: stevel
Date: Tue Aug 22 16:07:49 2006
New Revision: 433794

URL: http://svn.apache.org/viewvc?rev=433794&view=rev
Log:
This is slick. Instead of printing ANT_HOME/lib in the message, we print the real directory set where libs can be added. And, if ant.home is not set, we decide this is an IDE and tell the user that too.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java?rev=433794&r1=433793&r2=433794&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Tue Aug 22 16:07:49 2006
@@ -837,6 +837,36 @@
         boolean antTask;
         String home = System.getProperty(Launcher.USER_HOMEDIR);
         File libDir = new File(home, Launcher.USER_LIBDIR);
+        String antHomeLib;
+        boolean probablyIDE=false;
+        String anthome = System.getProperty(MagicNames.ANT_HOME);
+        if(anthome!=null) {
+            File antHomeLibDir = new File(anthome,"lib");
+            antHomeLib=antHomeLibDir.getAbsolutePath();
+        } else {
+            //running under an IDE that doesn't set ANT_HOME
+            probablyIDE=true;
+            antHomeLib = "ANT_HOME" +File.separatorChar +"lib";
+        }
+        StringBuffer dirListingText = new StringBuffer();
+        final String tab = "        -";
+        dirListingText.append(tab);
+        dirListingText.append(antHomeLib);
+        dirListingText.append('\n');
+        if(probablyIDE) {
+            dirListingText.append(tab);
+            dirListingText.append("the IDE Ant configuration dialogs");
+        } else {
+            dirListingText.append(tab);
+            dirListingText.append(libDir);
+            dirListingText.append('\n');
+            dirListingText.append(tab);
+            dirListingText.append(
+                    "a directory added on the command line with the -lib argument");
+        }
+
+        String dirListing=dirListingText.toString();
+        
         //look up the name
         AntTypeDefinition def = getDefinition(componentName);
         if (def == null) {
@@ -849,9 +879,8 @@
             if (isAntlib) {
                 out.println();
                 out.println("This appears to be an antlib declaration. ");
-                out.println("Action: Check that the implementing library exists "
-                        + "in ANT_HOME/lib or in ");
-                out.println("        " + libDir);
+                out.println("Action: Check that the implementing library exists in one of:");
+                out.println(dirListing);
             }
             definitions = true;
         } else {
@@ -870,13 +899,12 @@
                 jars = true;
                 if (optional) {
                     out.println("        This looks like one of Ant's optional components.");
-                    out.println("Action: Check that the appropriate optional JAR exists "
-                            + "in ANT_HOME/lib or in ");
-                    out.println("        " + libDir);
+                    out.println("Action: Check that the appropriate optional JAR exists in");
+                    out.println(dirListing);
                 } else {
                     out.println("Action: Check that the component has been correctly declared");
-                    out.println("        and that the implementing JAR is in ANT_HOME/lib or in");
-                    out.println("        " + libDir);
+                    out.println("        and that the implementing JAR is in one of:");
+                    out.println(dirListing);
                     definitions = true;
                 }
             } catch (NoClassDefFoundError ncdfe) {
@@ -884,15 +912,14 @@
                 out.println("Cause: Could not load a dependent class "
                         +  ncdfe.getMessage());
                 if (optional) {
-                    out.println("       It is not enough to have Ant's optional JAR, you need the JAR");
-                    out.println("       files that it depends upon.");
-                    out.println("Ant's optional task dependencies are listed in the manual.");
+                    out.println("       It is not enough to have Ant's optional JARs");
+                    out.println("       you need the JAR files that the optional tasks depend upon.");
+                    out.println("       Ant's optional task dependencies are listed in the manual.");
                 } else {
                     out.println("       This class may be in a separate JAR that is not installed.");
                 }
-                out.println("Action: Determine what extra JAR files are needed, and place them");
-                out.println("        in ANT_HOME/lib or");
-                out.println("        in " + libDir);
+                out.println("Action: Determine what extra JAR files are needed, and place them in one of:");
+                out.println(dirListing);
             }
             //here we successfully loaded the class or failed.
             if (clazz != null) {
@@ -925,9 +952,8 @@
                     out.println("Cause:  A class needed by class "
                             + classname + " cannot be found: ");
                     out.println("       " + ncdfe.getMessage());
-                    out.println("Action: Determine what extra JAR files are needed, and place them");
-                    out.println("        in ANT_HOME/lib or");
-                    out.println("        in " + libDir);
+                    out.println("Action: Determine what extra JAR files are needed, and place them in:");
+                    out.println(dirListing);
                 }
             }
             out.println();



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