You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by jk...@apache.org on 2006/03/25 22:27:53 UTC

svn commit: r388834 - in /ant/core/trunk/src: main/org/apache/tools/ant/ main/org/apache/tools/ant/launch/ main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/optional/extension/ testcases/org/apache/tools/ant/taskdefs/ testcases/org...

Author: jkf
Date: Sat Mar 25 13:27:51 2006
New Revision: 388834

URL: http://svn.apache.org/viewcvs?rev=388834&view=rev
Log:
Improved use of MagicNames for ant internal properties

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java
    ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java
    ant/core/trunk/src/main/org/apache/tools/ant/Project.java
    ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
    ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java
    ant/core/trunk/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java Sat Mar 25 13:27:51 2006
@@ -107,7 +107,7 @@
      * <tt>null</tt> if an error occurs.
      */
     public static File[] listLibraries() {
-        String home = System.getProperty(Launcher.ANTHOME_PROPERTY);
+        String home = System.getProperty(MagicNames.ANT_HOME);
         if (home == null) {
             return null;
         }
@@ -334,7 +334,7 @@
      * @param out the stream to print the content to
      */
     private static void doReportAntHomeLibraries(PrintStream out) {
-        out.println("ant.home: " + System.getProperty("ant.home"));
+        out.println(MagicNames.ANT_HOME + ": " + System.getProperty(MagicNames.ANT_HOME));
         File[] libs = listLibraries();
         printLibraries(libs, out);
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java Sat Mar 25 13:27:51 2006
@@ -103,6 +103,17 @@
      * Value: {@value}
      */
     public static final String ANT_FILE = "ant.file";
+
+    /**
+     * Property used to store the java version ant is running in.
+     */
+    public static final String ANT_JAVA_VERSION = "ant.java.version";
+
+    /**
+     * Property used to store the location of ant.
+     */
+    public static final String ANT_HOME = "ant.home";
+
     /**
      * property for regular expression implementation.
      * Value: {@value}

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Project.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/Project.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Project.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Project.java Sat Mar 25 13:27:51 2006
@@ -190,9 +190,10 @@
 
     /**
      * Property used to store the java version ant is running in.
+     * @deprecated
      */
-    public static final String ANT_JAVA_VERSION = "ant.java.version";
-
+    public static final String ANT_JAVA_VERSION = MagicNames.ANT_JAVA_VERSION;
+    
     /**
      * Set the input handler.
      *
@@ -739,7 +740,7 @@
                 + " is not a directory");
         }
         this.baseDir = baseDir;
-        setPropertyInternal("basedir", this.baseDir.getPath());
+        setPropertyInternal(MagicNames.PROJECT_BASEDIR, this.baseDir.getPath());
         String msg = "Project base dir set to: " + this.baseDir;
          log(msg, MSG_VERBOSE);
     }
@@ -807,7 +808,7 @@
      */
     public void setJavaVersionProperty() throws BuildException {
         String javaVersion = JavaEnvUtils.getJavaVersion();
-        setPropertyInternal(ANT_JAVA_VERSION, javaVersion);
+        setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion);
 
         // sanity check
         if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)

Modified: ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java Sat Mar 25 13:27:51 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright  2003-2005 The Apache Software Foundation
+ * Copyright  2003-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import org.apache.tools.ant.MagicNames;
+
 
 /**
  * This is a launcher for Ant.
@@ -36,8 +38,9 @@
     /**
      * The Ant Home (installation) Directory property.
      * {@value}
+     * @deprecated
      */
-    public static final String ANTHOME_PROPERTY = "ant.home";
+    public static final String ANTHOME_PROPERTY = MagicNames.ANT_HOME;
 
     /**
      * The Ant Library Directory property.
@@ -141,7 +144,7 @@
      */
     private void run(String[] args)
             throws LaunchException, MalformedURLException {
-        String antHomeProperty = System.getProperty(ANTHOME_PROPERTY);
+        String antHomeProperty = System.getProperty(MagicNames.ANT_HOME);
         File antHome = null;
 
         File sourceJar = Locator.getClassSource(getClass());
@@ -153,7 +156,7 @@
 
         if (antHome == null || !antHome.exists()) {
             antHome = jarDir.getParentFile();
-            System.setProperty(ANTHOME_PROPERTY, antHome.getAbsolutePath());
+            System.setProperty(MagicNames.ANT_HOME, antHome.getAbsolutePath());
         }
 
         if (!antHome.exists()) {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java Sat Mar 25 13:27:51 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright  2000,2002,2004-2005 The Apache Software Foundation
+ * Copyright  2000,2002,2004-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -24,7 +24,9 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
+
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 
@@ -96,9 +98,9 @@
                 if (myos.toLowerCase().indexOf("nt") >= 0) {
                     command = "cmd /c cd " + dir + " && " + command;
                 } else {
-                    String ant = getProject().getProperty("ant.home");
+                    String ant = getProject().getProperty(MagicNames.ANT_HOME);
                     if (ant == null) {
-                        throw new BuildException("Property 'ant.home' not "
+                        throw new BuildException("Property '" + MagicNames.ANT_HOME + "' not "
                             + "found", getLocation());
                     }
 
@@ -107,9 +109,9 @@
                 }
             }
         } else {
-            String ant = getProject().getProperty("ant.home");
+            String ant = getProject().getProperty(MagicNames.ANT_HOME);
             if (ant == null) {
-              throw new BuildException("Property 'ant.home' not found",
+              throw new BuildException("Property '" + MagicNames.ANT_HOME + "' not found",
                                        getLocation());
             }
             String antRun = getProject().resolveFile(ant + "/bin/antRun").toString();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java Sat Mar 25 13:27:51 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright  2000-2005 The Apache Software Foundation
+ * Copyright  2000-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
 import java.util.Vector;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.taskdefs.condition.Os;
@@ -1002,10 +1003,10 @@
                     + "No project provided");
             }
             // Locate the auxiliary script
-            String antHome = project.getProperty("ant.home");
+            String antHome = project.getProperty(MagicNames.ANT_HOME);
             if (antHome == null) {
                 throw new IOException("Cannot locate antRun script: "
-                    + "Property 'ant.home' not found");
+                    + "Property '" + MagicNames.ANT_HOME + "' not found");
             }
             String antRun = project.resolveFile(antHome + File.separator 
                                                 + myScript).toString();
@@ -1060,10 +1061,10 @@
                     + "No project provided");
             }
             // Locate the auxiliary script
-            String antHome = project.getProperty("ant.home");
+            String antHome = project.getProperty(MagicNames.ANT_HOME);
             if (antHome == null) {
                 throw new IOException("Cannot locate antRun script: "
-                    + "Property 'ant.home' not found");
+                    + "Property '" + MagicNames.ANT_HOME + "' not found");
             }
             String antRun = project.resolveFile(antHome + File.separator 
                                                 + myScript).toString();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java Sat Mar 25 13:27:51 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright  2002-2005 The Apache Software Foundation
+ * Copyright  2002-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 
@@ -147,7 +148,7 @@
         final Attributes attributes = manifest.getMainAttributes();
 
         attributes.put(Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION);
-        final String createdBy = "Apache Ant " + getProject().getProperty("ant.version");
+        final String createdBy = "Apache Ant " + getProject().getProperty(MagicNames.ANT_VERSION);
         attributes.putValue(CREATED_BY, createdBy);
 
         appendExtraAttributes(attributes);

Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java Sat Mar 25 13:27:51 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright  2002,2004-2005 The Apache Software Foundation
+ * Copyright  2002,2004-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 
 package org.apache.tools.ant.taskdefs;
 
+import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.Commandline;
@@ -50,7 +51,7 @@
         ej.setTimeout(new Long(TIME_OUT));
         project = new Project();
         project.setBasedir(".");
-        project.setProperty("ant.home", System.getProperty("ant.home"));
+        project.setProperty(MagicNames.ANT_HOME, System.getProperty(MagicNames.ANT_HOME));
         cp = new Path(project, getTestClassPath());
         ej.setClasspath(cp);
     }

Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java?rev=388834&r1=388833&r2=388834&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java Sat Mar 25 13:27:51 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright  2000-2005 The Apache Software Foundation
+ * Copyright  2000-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
 package org.apache.tools.ant.types;
 
 import junit.framework.TestCase;
+
+import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.util.JavaEnvUtils;
 
@@ -78,7 +80,7 @@
 
         c.createClasspath(project).setLocation(project.resolveFile("build.xml"));
         c.createClasspath(project).setLocation(project.resolveFile(
-            System.getProperty("ant.home")+"/lib/ant.jar"));
+            System.getProperty(MagicNames.ANT_HOME)+"/lib/ant.jar"));
         s = c.getCommandline();
         assertEquals("with classpath", 6, s.length);
         //        assertEquals("with classpath", "java", s[0]);



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