git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278417 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -23,7 +23,16 @@ package org.apache.tools.ant; | |||||
| * | * | ||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| */ | */ | ||||
| public class MagicNames { | |||||
| public final class MagicNames { | |||||
| /** | |||||
| * Ant version property. {@value} | |||||
| */ | |||||
| public static final String ANT_VERSION = "ant.version"; | |||||
| private MagicNames() { | |||||
| } | |||||
| /** | /** | ||||
| * The name of the script repository used by the script repo task | * The name of the script repository used by the script repo task | ||||
| * Value {@value} | * Value {@value} | ||||
| @@ -62,5 +71,27 @@ public class MagicNames { | |||||
| public static final String TYPEDEFS_PROPERTIES_RESOURCE = | public static final String TYPEDEFS_PROPERTIES_RESOURCE = | ||||
| "/org/apache/tools/ant/types/defaults.properties"; | "/org/apache/tools/ant/types/defaults.properties"; | ||||
| /** | |||||
| * Reference to the current Ant executor | |||||
| * Value: {@value} | |||||
| */ | |||||
| public static final String ANT_EXECUTOR_REFERENCE = "ant.executor"; | |||||
| /** | |||||
| * Property defining the classname of an executor. | |||||
| * Value: {@value} | |||||
| */ | |||||
| public static final String ANT_EXECUTOR_CLASSNAME = "ant.executor.class"; | |||||
| /** | |||||
| * property name for basedir of the project | |||||
| * Value: {@value} | |||||
| */ | |||||
| public static final String PROJECT_BASEDIR = "basedir"; | |||||
| /** | |||||
| * property for ant file name | |||||
| * Value: {@value} | |||||
| */ | |||||
| public static final String ANT_FILE = "ant.file"; | |||||
| } | } | ||||
| @@ -46,7 +46,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class Main implements AntMain { | public class Main implements AntMain { | ||||
| /** The default build file name. */ | |||||
| /** The default build file name. {@value} */ | |||||
| public static final String DEFAULT_BUILD_FILENAME = "build.xml"; | public static final String DEFAULT_BUILD_FILENAME = "build.xml"; | ||||
| /** Our current message output status. Follows Project.MSG_XXX. */ | /** Our current message output status. Follows Project.MSG_XXX. */ | ||||
| @@ -628,7 +628,7 @@ public class Main implements AntMain { | |||||
| } | } | ||||
| project.init(); | project.init(); | ||||
| project.setUserProperty("ant.version", getAntVersion()); | |||||
| project.setUserProperty(MagicNames.ANT_VERSION, getAntVersion()); | |||||
| // set user-define properties | // set user-define properties | ||||
| Enumeration e = definedProps.keys(); | Enumeration e = definedProps.keys(); | ||||
| @@ -638,7 +638,7 @@ public class Main implements AntMain { | |||||
| project.setUserProperty(arg, value); | project.setUserProperty(arg, value); | ||||
| } | } | ||||
| project.setUserProperty("ant.file", | |||||
| project.setUserProperty(MagicNames.ANT_FILE, | |||||
| buildFile.getAbsolutePath()); | buildFile.getAbsolutePath()); | ||||
| project.setKeepGoingMode(keepGoingMode); | project.setKeepGoingMode(keepGoingMode); | ||||
| @@ -184,6 +184,7 @@ public class Project { | |||||
| * Flag which catches Listeners which try to use System.out or System.err . | * Flag which catches Listeners which try to use System.out or System.err . | ||||
| */ | */ | ||||
| private boolean loggingMessage = false; | private boolean loggingMessage = false; | ||||
| public static final String ANT_JAVA_VERSION = "ant.java.version"; | |||||
| /** | /** | ||||
| * Set the input handler. | * Set the input handler. | ||||
| @@ -794,7 +795,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void setJavaVersionProperty() throws BuildException { | public void setJavaVersionProperty() throws BuildException { | ||||
| String javaVersion = JavaEnvUtils.getJavaVersion(); | String javaVersion = JavaEnvUtils.getJavaVersion(); | ||||
| setPropertyInternal("ant.java.version", javaVersion); | |||||
| setPropertyInternal(ANT_JAVA_VERSION, javaVersion); | |||||
| // sanity check | // sanity check | ||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)) { | if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)) { | ||||
| @@ -1038,7 +1039,7 @@ public class Project { | |||||
| * @param e the Executor to use. | * @param e the Executor to use. | ||||
| */ | */ | ||||
| public void setExecutor(Executor e) { | public void setExecutor(Executor e) { | ||||
| addReference("ant.executor", e); | |||||
| addReference(MagicNames.ANT_EXECUTOR_REFERENCE, e); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1046,9 +1047,9 @@ public class Project { | |||||
| * @return an Executor instance. | * @return an Executor instance. | ||||
| */ | */ | ||||
| public Executor getExecutor() { | public Executor getExecutor() { | ||||
| Object o = getReference("ant.executor"); | |||||
| Object o = getReference(MagicNames.ANT_EXECUTOR_REFERENCE); | |||||
| if (o == null) { | if (o == null) { | ||||
| String classname = getProperty("ant.executor.class"); | |||||
| String classname = getProperty(MagicNames.ANT_EXECUTOR_CLASSNAME); | |||||
| if (classname == null) { | if (classname == null) { | ||||
| classname = DefaultExecutor.class.getName(); | classname = DefaultExecutor.class.getName(); | ||||
| } | } | ||||
| @@ -36,6 +36,8 @@ import org.apache.tools.ant.ProjectComponent; | |||||
| import org.apache.tools.ant.ProjectHelper; | import org.apache.tools.ant.ProjectHelper; | ||||
| import org.apache.tools.ant.Target; | import org.apache.tools.ant.Target; | ||||
| import org.apache.tools.ant.Task; | 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.types.PropertySet; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -119,8 +121,6 @@ public class Ant extends Task { | |||||
| } | } | ||||
| /** | /** | ||||
| * If true, pass all properties to the new Ant project. | * If true, pass all properties to the new Ant project. | ||||
| * Defaults to true. | * Defaults to true. | ||||
| @@ -297,7 +297,7 @@ public class Ant extends Task { | |||||
| newProject.setBaseDir(dir); | newProject.setBaseDir(dir); | ||||
| if (savedDir != null) { | if (savedDir != null) { | ||||
| // has been set explicitly | // has been set explicitly | ||||
| newProject.setInheritedProperty("basedir" , | |||||
| newProject.setInheritedProperty(MagicNames.PROJECT_BASEDIR , | |||||
| dir.getAbsolutePath()); | dir.getAbsolutePath()); | ||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -307,7 +307,7 @@ public class Ant extends Task { | |||||
| overrideProperties(); | overrideProperties(); | ||||
| if (antFile == null) { | if (antFile == null) { | ||||
| antFile = "build.xml"; | |||||
| antFile = Main.DEFAULT_BUILD_FILENAME; | |||||
| } | } | ||||
| File file = FILE_UTILS.resolveFile(dir, antFile); | File file = FILE_UTILS.resolveFile(dir, antFile); | ||||
| @@ -316,9 +316,9 @@ public class Ant extends Task { | |||||
| log("calling target(s) " | log("calling target(s) " | ||||
| + ((locals.size() > 0) ? locals.toString() : "[default]") | + ((locals.size() > 0) ? locals.toString() : "[default]") | ||||
| + " in build file " + antFile, Project.MSG_VERBOSE); | + " 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 | // Are we trying to call the target in which we are defined (or | ||||
| // the build file if this is a top level task)? | // the build file if this is a top level task)? | ||||
| if (thisAntFile != null | if (thisAntFile != null | ||||
| @@ -350,8 +350,8 @@ public class Ant extends Task { | |||||
| } | } | ||||
| } | } | ||||
| if (newProject.getProperty("ant.file") | |||||
| .equals(getProject().getProperty("ant.file")) | |||||
| if (newProject.getProperty(MagicNames.ANT_FILE) | |||||
| .equals(getProject().getProperty(MagicNames.ANT_FILE)) | |||||
| && getOwningTarget() != null) { | && getOwningTarget() != null) { | ||||
| String owningTargetName = getOwningTarget().getName(); | String owningTargetName = getOwningTarget().getName(); | ||||
| @@ -558,7 +558,7 @@ public class Ant extends Task { | |||||
| Enumeration e = props.keys(); | Enumeration e = props.keys(); | ||||
| while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
| String key = e.nextElement().toString(); | 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() | // basedir and ant.file get special treatment in execute() | ||||
| continue; | continue; | ||||
| } | } | ||||