📄 project.java
字号:
} /** * Set the name of the project, also setting the user * property <code>ant.project.name</code>. * * @param name The name of the project. * Must not be <code>null</code>. */ public void setName(String name) { setUserProperty("ant.project.name", name); this.name = name; } /** * Return the project name, if one has been set. * * @return the project name, or <code>null</code> if it hasn't been set. */ public String getName() { return name; } /** * Set the project description. * * @param description The description of the project. * May be <code>null</code>. */ public void setDescription(String description) { this.description = description; } /** * Return the project description, if one has been set. * * @return the project description, or <code>null</code> if it hasn't * been set. */ public String getDescription() { if (description == null) { description = Description.getDescription(this); } return description; } /** * Add a filter to the set of global filters. * * @param token The token to filter. * Must not be <code>null</code>. * @param value The replacement value. * Must not be <code>null</code>. * @deprecated since 1.4.x. * Use getGlobalFilterSet().addFilter(token,value) * * @see #getGlobalFilterSet() * @see FilterSet#addFilter(String,String) */ public void addFilter(String token, String value) { if (token == null) { return; } globalFilterSet.addFilter(new FilterSet.Filter(token, value)); } /** * Return a hashtable of global filters, mapping tokens to values. * * @return a hashtable of global filters, mapping tokens to values * (String to String). * * @deprecated since 1.4.x * Use getGlobalFilterSet().getFilterHash(). * * @see #getGlobalFilterSet() * @see FilterSet#getFilterHash() */ public Hashtable getFilters() { // we need to build the hashtable dynamically return globalFilterSet.getFilterHash(); } /** * Set the base directory for the project, checking that * the given filename exists and is a directory. * * @param baseD The project base directory. * Must not be <code>null</code>. * * @exception BuildException if the directory if invalid. */ public void setBasedir(String baseD) throws BuildException { setBaseDir(new File(baseD)); } /** * Set the base directory for the project, checking that * the given file exists and is a directory. * * @param baseDir The project base directory. * Must not be <code>null</code>. * @exception BuildException if the specified file doesn't exist or * isn't a directory. */ public void setBaseDir(File baseDir) throws BuildException { baseDir = FILE_UTILS.normalize(baseDir.getAbsolutePath()); if (!baseDir.exists()) { throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " does not exist"); } if (!baseDir.isDirectory()) { throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " is not a directory"); } this.baseDir = baseDir; setPropertyInternal(MagicNames.PROJECT_BASEDIR, this.baseDir.getPath()); String msg = "Project base dir set to: " + this.baseDir; log(msg, MSG_VERBOSE); } /** * Return the base directory of the project as a file object. * * @return the project base directory, or <code>null</code> if the * base directory has not been successfully set to a valid value. */ public File getBaseDir() { if (baseDir == null) { try { setBasedir("."); } catch (BuildException ex) { ex.printStackTrace(); } } return baseDir; } /** * Set "keep-going" mode. In this mode Ant will try to execute * as many targets as possible. All targets that do not depend * on failed target(s) will be executed. If the keepGoing settor/getter * methods are used in conjunction with the <code>ant.executor.class</code> * property, they will have no effect. * @param keepGoingMode "keep-going" mode * @since Ant 1.6 */ public void setKeepGoingMode(boolean keepGoingMode) { this.keepGoingMode = keepGoingMode; } /** * Return the keep-going mode. If the keepGoing settor/getter * methods are used in conjunction with the <code>ant.executor.class</code> * property, they will have no effect. * @return "keep-going" mode * @since Ant 1.6 */ public boolean isKeepGoingMode() { return this.keepGoingMode; } /** * Return the version of Java this class is running under. * @return the version of Java as a String, e.g. "1.1" . * @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion * @deprecated since 1.5.x. * Use org.apache.tools.ant.util.JavaEnvUtils instead. */ public static String getJavaVersion() { return JavaEnvUtils.getJavaVersion(); } /** * Set the <code>ant.java.version</code> property and tests for * unsupported JVM versions. If the version is supported, * verbose log messages are generated to record the Java version * and operating system name. * * @exception BuildException if this Java version is not supported. * * @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion */ public void setJavaVersionProperty() throws BuildException { String javaVersion = JavaEnvUtils.getJavaVersion(); setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion); // sanity check if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0) || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { throw new BuildException("Ant cannot work on Java 1.0 / 1.1"); } log("Detected Java version: " + javaVersion + " in: " + System.getProperty("java.home"), MSG_VERBOSE); log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE); } /** * Add all system properties which aren't already defined as * user properties to the project properties. */ public void setSystemProperties() { Properties systemP = System.getProperties(); Enumeration e = systemP.propertyNames(); while (e.hasMoreElements()) { String propertyName = (String) e.nextElement(); String value = systemP.getProperty(propertyName); if (value != null) { this.setPropertyInternal(propertyName, value); } } } /** * Add a new task definition to the project. * Attempting to override an existing definition with an * equivalent one (i.e. with the same classname) results in * a verbose log message. Attempting to override an existing definition * with a different one results in a warning log message and * invalidates any tasks which have already been created with the * old definition. * * @param taskName The name of the task to add. * Must not be <code>null</code>. * @param taskClass The full name of the class implementing the task. * Must not be <code>null</code>. * * @exception BuildException if the class is unsuitable for being an Ant * task. An error level message is logged before * this exception is thrown. * * @see #checkTaskClass(Class) */ public void addTaskDefinition(String taskName, Class taskClass) throws BuildException { ComponentHelper.getComponentHelper(this).addTaskDefinition(taskName, taskClass); } /** * Check whether or not a class is suitable for serving as Ant task. * Ant task implementation classes must be public, concrete, and have * a no-arg constructor. * * @param taskClass The class to be checked. * Must not be <code>null</code>. * * @exception BuildException if the class is unsuitable for being an Ant * task. An error level message is logged before * this exception is thrown. */ public void checkTaskClass(final Class taskClass) throws BuildException { ComponentHelper.getComponentHelper(this).checkTaskClass(taskClass); if (!Modifier.isPublic(taskClass.getModifiers())) { final String message = taskClass + " is not public"; log(message, Project.MSG_ERR); throw new BuildException(message); } if (Modifier.isAbstract(taskClass.getModifiers())) { final String message = taskClass + " is abstract"; log(message, Project.MSG_ERR); throw new BuildException(message); } try { taskClass.getConstructor((Class[]) null); // don't have to check for public, since // getConstructor finds public constructors only. } catch (NoSuchMethodException e) { final String message = "No public no-arg constructor in " + taskClass; log(message, Project.MSG_ERR); throw new BuildException(message); } catch (LinkageError e) { String message = "Could not load " + taskClass + ": " + e; log(message, Project.MSG_ERR); throw new BuildException(message, e); } if (!Task.class.isAssignableFrom(taskClass)) { TaskAdapter.checkTaskClass(taskClass, this); } } /** * Return the current task definition hashtable. The returned hashtable is * "live" and so should not be modified. * * @return a map of from task name to implementing class * (String to Class). */ public Hashtable getTaskDefinitions() { return ComponentHelper.getComponentHelper(this).getTaskDefinitions(); } /** * Add a new datatype definition. * Attempting to override an existing definition with an * equivalent one (i.e. with the same classname) results in * a verbose log message. Attempting to override an existing definition * with a different one results in a warning log message, but the * definition is changed. * * @param typeName The name of the datatype. * Must not be <code>null</code>. * @param typeClass The full name of the class implementing the datatype. * Must not be <code>null</code>. */ public void addDataTypeDefinition(String typeName, Class typeClass) { ComponentHelper.getComponentHelper(this).addDataTypeDefinition(typeName, typeClass); } /** * Return the current datatype definition hashtable. The returned * hashtable is "live" and so should not be modified. * * @return a map of from datatype name to implementing class * (String to Class). */ public Hashtable getDataTypeDefinitions() { return ComponentHelper.getComponentHelper(this).getDataTypeDefinitions(); } /** * Add a <em>new</em> target to the project. * * @param target The target to be added to the project. * Must not be <code>null</code>. * * @exception BuildException if the target already exists in the project * * @see Project#addOrReplaceTarget(Target) */ public void addTarget(Target target) throws BuildException { addTarget(target.getName(), target); } /** * Add a <em>new</em> target to the project. * * @param targetName The name to use for the target. * Must not be <code>null</code>. * @param target The target to be added to the project. * Must not be <code>null</code>. * * @exception BuildException if the target already exists in the project. * * @see Project#addOrReplaceTarget(String, Target) */ public void addTarget(String targetName, Target target) throws BuildException { if (targets.get(targetName) != null) { throw new BuildException("Duplicate target: `" + targetName + "'"); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -