stevel 2005/06/10 16:06:11 Modified: src/main/org/apache/tools/ant MagicNames.java Main.java Project.java src/main/org/apache/tools/ant/taskdefs Ant.java Log: moving some magic names into place, using them where needed. Revision Changes Path 1.9 +32 -1 ant/src/main/org/apache/tools/ant/MagicNames.java Index: MagicNames.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/MagicNames.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MagicNames.java 1 Mar 2005 15:55:29 -0000 1.8 +++ MagicNames.java 10 Jun 2005 23:06:10 -0000 1.9 @@ -23,7 +23,16 @@ * * @since Ant 1.6 */ -public class MagicNames { +public final class MagicNames { + /** + * Ant version property. [EMAIL PROTECTED] + */ + public static final String ANT_VERSION = "ant.version"; + + private MagicNames() { + } + + /** * The name of the script repository used by the script repo task * Value [EMAIL PROTECTED] @@ -62,5 +71,27 @@ public static final String TYPEDEFS_PROPERTIES_RESOURCE = "/org/apache/tools/ant/types/defaults.properties"; + /** + * Reference to the current Ant executor + * Value: [EMAIL PROTECTED] + */ + public static final String ANT_EXECUTOR_REFERENCE = "ant.executor"; + + /** + * Property defining the classname of an executor. + * Value: [EMAIL PROTECTED] + */ + public static final String ANT_EXECUTOR_CLASSNAME = "ant.executor.class"; + /** + * property name for basedir of the project + * Value: [EMAIL PROTECTED] + */ + public static final String PROJECT_BASEDIR = "basedir"; + /** + * property for ant file name + * Value: [EMAIL PROTECTED] + */ + public static final String ANT_FILE = "ant.file"; + } 1.121 +3 -3 ant/src/main/org/apache/tools/ant/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Main.java,v retrieving revision 1.120 retrieving revision 1.121 diff -u -r1.120 -r1.121 --- Main.java 26 May 2005 22:11:57 -0000 1.120 +++ Main.java 10 Jun 2005 23:06:10 -0000 1.121 @@ -46,7 +46,7 @@ */ public class Main implements AntMain { - /** The default build file name. */ + /** The default build file name. [EMAIL PROTECTED] */ public static final String DEFAULT_BUILD_FILENAME = "build.xml"; /** Our current message output status. Follows Project.MSG_XXX. */ @@ -628,7 +628,7 @@ } project.init(); - project.setUserProperty("ant.version", getAntVersion()); + project.setUserProperty(MagicNames.ANT_VERSION, getAntVersion()); // set user-define properties Enumeration e = definedProps.keys(); @@ -638,7 +638,7 @@ project.setUserProperty(arg, value); } - project.setUserProperty("ant.file", + project.setUserProperty(MagicNames.ANT_FILE, buildFile.getAbsolutePath()); project.setKeepGoingMode(keepGoingMode); 1.193 +5 -4 ant/src/main/org/apache/tools/ant/Project.java Index: Project.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.192 retrieving revision 1.193 diff -u -r1.192 -r1.193 --- Project.java 26 May 2005 17:01:01 -0000 1.192 +++ Project.java 10 Jun 2005 23:06:10 -0000 1.193 @@ -184,6 +184,7 @@ * Flag which catches Listeners which try to use System.out or System.err . */ private boolean loggingMessage = false; + public static final String ANT_JAVA_VERSION = "ant.java.version"; /** * Set the input handler. @@ -794,7 +795,7 @@ */ public void setJavaVersionProperty() throws BuildException { String javaVersion = JavaEnvUtils.getJavaVersion(); - setPropertyInternal("ant.java.version", javaVersion); + setPropertyInternal(ANT_JAVA_VERSION, javaVersion); // sanity check if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)) { @@ -1038,7 +1039,7 @@ * @param e the Executor to use. */ public void setExecutor(Executor e) { - addReference("ant.executor", e); + addReference(MagicNames.ANT_EXECUTOR_REFERENCE, e); } /** @@ -1046,9 +1047,9 @@ * @return an Executor instance. */ public Executor getExecutor() { - Object o = getReference("ant.executor"); + Object o = getReference(MagicNames.ANT_EXECUTOR_REFERENCE); if (o == null) { - String classname = getProperty("ant.executor.class"); + String classname = getProperty(MagicNames.ANT_EXECUTOR_CLASSNAME); if (classname == null) { classname = DefaultExecutor.class.getName(); } 1.123 +9 -9 ant/src/main/org/apache/tools/ant/taskdefs/Ant.java Index: Ant.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v retrieving revision 1.122 retrieving revision 1.123 diff -u -r1.122 -r1.123 --- Ant.java 26 May 2005 17:01:01 -0000 1.122 +++ Ant.java 10 Jun 2005 23:06:11 -0000 1.123 @@ -36,6 +36,8 @@ import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.Target; import org.apache.tools.ant.Task; +import org.apache.tools.ant.MagicNames; +import org.apache.tools.ant.Main; import org.apache.tools.ant.types.PropertySet; import org.apache.tools.ant.util.FileUtils; @@ -119,8 +121,6 @@ } - - /** * If true, pass all properties to the new Ant project. * Defaults to true. @@ -297,7 +297,7 @@ newProject.setBaseDir(dir); if (savedDir != null) { // has been set explicitly - newProject.setInheritedProperty("basedir" , + newProject.setInheritedProperty(MagicNames.PROJECT_BASEDIR , dir.getAbsolutePath()); } } else { @@ -307,7 +307,7 @@ overrideProperties(); if (antFile == null) { - antFile = "build.xml"; + antFile = Main.DEFAULT_BUILD_FILENAME; } File file = FILE_UTILS.resolveFile(dir, antFile); @@ -316,9 +316,9 @@ log("calling target(s) " + ((locals.size() > 0) ? locals.toString() : "[default]") + " in build file " + antFile, Project.MSG_VERBOSE); - newProject.setUserProperty("ant.file" , antFile); + newProject.setUserProperty(MagicNames.ANT_FILE , antFile); - String thisAntFile = getProject().getProperty("ant.file"); + String thisAntFile = getProject().getProperty(MagicNames.ANT_FILE); // Are we trying to call the target in which we are defined (or // the build file if this is a top level task)? if (thisAntFile != null @@ -350,8 +350,8 @@ } } - if (newProject.getProperty("ant.file") - .equals(getProject().getProperty("ant.file")) + if (newProject.getProperty(MagicNames.ANT_FILE) + .equals(getProject().getProperty(MagicNames.ANT_FILE)) && getOwningTarget() != null) { String owningTargetName = getOwningTarget().getName(); @@ -558,7 +558,7 @@ Enumeration e = props.keys(); while (e.hasMoreElements()) { String key = e.nextElement().toString(); - if ("basedir".equals(key) || "ant.file".equals(key)) { + if (MagicNames.PROJECT_BASEDIR.equals(key) || MagicNames.ANT_FILE.equals(key)) { // basedir and ant.file get special treatment in execute() continue; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]