git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274954 13f79535-47bb-0310-9956-ffa450edef68master
@@ -175,6 +175,10 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
* The size of buffers to be used in this classloader. | * The size of buffers to be used in this classloader. | ||||
*/ | */ | ||||
private static final int BUFFER_SIZE = 8192; | private static final int BUFFER_SIZE = 8192; | ||||
/** | |||||
* Number of array elements in a test array of strings | |||||
*/ | |||||
private static final int NUMBER_OF_STRINGS = 256; | |||||
/** | /** | ||||
* The components of the classpath that the classloader searches | * The components of the classpath that the classloader searches | ||||
@@ -549,7 +553,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
//At least one constructor is guaranteed to be there, but check anyway. | //At least one constructor is guaranteed to be there, but check anyway. | ||||
if (cons != null) { | if (cons != null) { | ||||
if (cons.length > 0 && cons[0] != null) { | if (cons.length > 0 && cons[0] != null) { | ||||
final String[] strs = new String[256]; | |||||
final String[] strs = new String[NUMBER_OF_STRINGS]; | |||||
try { | try { | ||||
cons[0].newInstance(strs); | cons[0].newInstance(strs); | ||||
// Expecting an exception to be thrown by this call: | // Expecting an exception to be thrown by this call: | ||||
@@ -70,7 +70,6 @@ import org.apache.tools.ant.types.selectors.FileSelector; | |||||
import org.apache.tools.ant.types.selectors.SelectorScanner; | import org.apache.tools.ant.types.selectors.SelectorScanner; | ||||
import org.apache.tools.ant.types.selectors.SelectorUtils; | import org.apache.tools.ant.types.selectors.SelectorUtils; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.taskdefs.condition.Os; | |||||
/** | /** | ||||
* Class for scanning a directory for files/directories which match certain | * Class for scanning a directory for files/directories which match certain | ||||
@@ -707,7 +706,7 @@ public class DirectoryScanner | |||||
if (!path.equals(currentelement)) { | if (!path.equals(currentelement)) { | ||||
myfile = findFile(basedir, currentelement); | myfile = findFile(basedir, currentelement); | ||||
if (myfile != null) { | if (myfile != null) { | ||||
currentelement = | |||||
currentelement = | |||||
fileUtils.removeLeadingPath(basedir, | fileUtils.removeLeadingPath(basedir, | ||||
myfile); | myfile); | ||||
} | } | ||||
@@ -716,7 +715,7 @@ public class DirectoryScanner | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
if ((myfile == null || !myfile.exists()) && !isCaseSensitive) { | if ((myfile == null || !myfile.exists()) && !isCaseSensitive) { | ||||
File f = findFileCaseInsensitive(basedir, currentelement); | File f = findFileCaseInsensitive(basedir, currentelement); | ||||
if (f.exists()) { | if (f.exists()) { | ||||
@@ -729,7 +728,7 @@ public class DirectoryScanner | |||||
} | } | ||||
if (myfile != null && myfile.exists()) { | if (myfile != null && myfile.exists()) { | ||||
if (!followSymlinks | |||||
if (!followSymlinks | |||||
&& isSymlink(basedir, currentelement)) { | && isSymlink(basedir, currentelement)) { | ||||
continue; | continue; | ||||
} | } | ||||
@@ -902,7 +901,7 @@ public class DirectoryScanner | |||||
if (!filesIncluded.contains(name) | if (!filesIncluded.contains(name) | ||||
&& !filesExcluded.contains(name) | && !filesExcluded.contains(name) | ||||
&& !filesDeselected.contains(name)) { | && !filesDeselected.contains(name)) { | ||||
if (!isExcluded(name)) { | if (!isExcluded(name)) { | ||||
if (isSelected(name, file)) { | if (isSelected(name, file)) { | ||||
filesIncluded.addElement(name); | filesIncluded.addElement(name); | ||||
@@ -942,7 +941,7 @@ public class DirectoryScanner | |||||
scandir(file, name + File.separator, fast); | scandir(file, name + File.separator, fast); | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
everythingIncluded = false; | everythingIncluded = false; | ||||
dirsExcluded.addElement(name); | dirsExcluded.addElement(name); | ||||
@@ -120,38 +120,70 @@ public class AntXMLContext { | |||||
* when processing a particular build file. | * when processing a particular build file. | ||||
*/ | */ | ||||
private boolean ignoreProjectTag = false; | private boolean ignoreProjectTag = false; | ||||
/** | |||||
* constructor | |||||
* @param project the project to which this antxml context belongs to | |||||
*/ | |||||
public AntXMLContext(Project project) { | public AntXMLContext(Project project) { | ||||
this.project = project; | this.project = project; | ||||
implicitTarget.setName(""); | implicitTarget.setName(""); | ||||
targetVector.addElement(implicitTarget); | targetVector.addElement(implicitTarget); | ||||
} | } | ||||
/** | |||||
* sets the build file to which the XML context belongs | |||||
* @param buildFile ant build file | |||||
*/ | |||||
public void setBuildFile(File buildFile) { | public void setBuildFile(File buildFile) { | ||||
this.buildFile = buildFile; | this.buildFile = buildFile; | ||||
this.buildFileParent = new File(buildFile.getParent()); | this.buildFileParent = new File(buildFile.getParent()); | ||||
} | } | ||||
/** | |||||
* find out the build file | |||||
* @return the build file to which the xml context belongs | |||||
*/ | |||||
public File getBuildFile() { | public File getBuildFile() { | ||||
return buildFile; | return buildFile; | ||||
} | } | ||||
/** | |||||
* find out the parent build file of this build file | |||||
* @return the parent build file of this build file | |||||
*/ | |||||
public File getBuildFileParent() { | public File getBuildFileParent() { | ||||
return buildFileParent; | return buildFileParent; | ||||
} | } | ||||
/** | |||||
* find out the project to which this antxml context belongs | |||||
* @return project | |||||
*/ | |||||
public Project getProject() { | public Project getProject() { | ||||
return project; | return project; | ||||
} | } | ||||
/** | |||||
* find out the current project name | |||||
* @return current project name | |||||
*/ | |||||
public String getCurrentProjectName() { | public String getCurrentProjectName() { | ||||
return currentProjectName; | return currentProjectName; | ||||
} | } | ||||
/** | |||||
* set the name of the current project | |||||
* @param name name of the current project | |||||
*/ | |||||
public void setCurrentProjectName(String name) { | public void setCurrentProjectName(String name) { | ||||
this.currentProjectName = name; | this.currentProjectName = name; | ||||
} | } | ||||
/** | |||||
* get the current runtime configurable wrapper | |||||
* can return null | |||||
* @return runtime configurable wrapper | |||||
*/ | |||||
public RuntimeConfigurable currentWrapper() { | public RuntimeConfigurable currentWrapper() { | ||||
if (wStack.size() < 1) { | if (wStack.size() < 1) { | ||||
return null; | return null; | ||||
@@ -159,6 +191,11 @@ public class AntXMLContext { | |||||
return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1); | return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1); | ||||
} | } | ||||
/** | |||||
* get the runtime configurable wrapper of the parent project | |||||
* can return null | |||||
* @return runtime configurable wrapper of the parent project | |||||
*/ | |||||
public RuntimeConfigurable parentWrapper() { | public RuntimeConfigurable parentWrapper() { | ||||
if (wStack.size() < 2) { | if (wStack.size() < 2) { | ||||
return null; | return null; | ||||
@@ -166,41 +203,76 @@ public class AntXMLContext { | |||||
return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2); | return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2); | ||||
} | } | ||||
/** | |||||
* add a runtime configurable wrapper to the internal stack | |||||
* @param wrapper runtime configurable wrapper | |||||
*/ | |||||
public void pushWrapper(RuntimeConfigurable wrapper) { | public void pushWrapper(RuntimeConfigurable wrapper) { | ||||
wStack.addElement(wrapper); | wStack.addElement(wrapper); | ||||
} | } | ||||
/** | |||||
* remove a runtime configurable wrapper from the stack | |||||
*/ | |||||
public void popWrapper() { | public void popWrapper() { | ||||
if (wStack.size() > 0) { | if (wStack.size() > 0) { | ||||
wStack.removeElementAt(wStack.size() - 1); | wStack.removeElementAt(wStack.size() - 1); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* access the stack of wrappers | |||||
* @return the stack of wrappers | |||||
*/ | |||||
public Vector getWrapperStack() { | public Vector getWrapperStack() { | ||||
return wStack; | return wStack; | ||||
} | } | ||||
/** | |||||
* add a new target | |||||
* @param target target to add | |||||
*/ | |||||
public void addTarget(Target target) { | public void addTarget(Target target) { | ||||
targetVector.addElement(target); | targetVector.addElement(target); | ||||
currentTarget = target; | currentTarget = target; | ||||
} | } | ||||
/** | |||||
* get the current target | |||||
* @return current target | |||||
*/ | |||||
public Target getCurrentTarget() { | public Target getCurrentTarget() { | ||||
return currentTarget; | return currentTarget; | ||||
} | } | ||||
/** | |||||
* get the implicit target | |||||
* @return implicit target | |||||
*/ | |||||
public Target getImplicitTarget() { | public Target getImplicitTarget() { | ||||
return implicitTarget; | return implicitTarget; | ||||
} | } | ||||
/** | |||||
* sets the current target | |||||
* @param target current target | |||||
*/ | |||||
public void setCurrentTarget(Target target) { | public void setCurrentTarget(Target target) { | ||||
this.currentTarget = target; | this.currentTarget = target; | ||||
} | } | ||||
/** | |||||
* sets the implicit target | |||||
* @param target | |||||
*/ | |||||
public void setImplicitTarget(Target target) { | public void setImplicitTarget(Target target) { | ||||
this.implicitTarget = target; | this.implicitTarget = target; | ||||
} | } | ||||
/** | |||||
* access the vector of targets | |||||
* @return vector of targets | |||||
*/ | |||||
public Vector getTargets() { | public Vector getTargets() { | ||||
return targetVector; | return targetVector; | ||||
} | } | ||||
@@ -212,8 +284,6 @@ public class AntXMLContext { | |||||
* <p> | * <p> | ||||
* This method was moved out of the configure method to allow | * This method was moved out of the configure method to allow | ||||
* it to be executed at parse time. | * it to be executed at parse time. | ||||
* | |||||
* @see #configure(java.lang.Object,org.xml.sax.AttributeList,org.apache.tools.ant.Project) | |||||
*/ | */ | ||||
public void configureId(Object element, Attributes attr) { | public void configureId(Object element, Attributes attr) { | ||||
String id = attr.getValue("id"); | String id = attr.getValue("id"); | ||||
@@ -222,18 +292,34 @@ public class AntXMLContext { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* access the locator | |||||
* @return locator | |||||
*/ | |||||
public Locator getLocator() { | public Locator getLocator() { | ||||
return locator; | return locator; | ||||
} | } | ||||
/** | |||||
* sets the locator | |||||
* @param locator locator | |||||
*/ | |||||
public void setLocator(Locator locator) { | public void setLocator(Locator locator) { | ||||
this.locator = locator; | this.locator = locator; | ||||
} | } | ||||
/** | |||||
* tells whether the project tag is being ignored | |||||
* @return whether the project tag is being ignored | |||||
*/ | |||||
public boolean isIgnoringProjectTag() { | public boolean isIgnoringProjectTag() { | ||||
return ignoreProjectTag; | return ignoreProjectTag; | ||||
} | } | ||||
/** | |||||
* sets the flag to ignore the project tag | |||||
* @param flag to ignore the project tag | |||||
*/ | |||||
public void setIgnoreProjectTag(boolean flag) { | public void setIgnoreProjectTag(boolean flag) { | ||||
this.ignoreProjectTag = flag; | this.ignoreProjectTag = flag; | ||||
} | } | ||||
@@ -121,6 +121,9 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
*/ | */ | ||||
private static FileUtils fu = FileUtils.newFileUtils(); | private static FileUtils fu = FileUtils.newFileUtils(); | ||||
/** | |||||
* default constructor | |||||
*/ | |||||
public ProjectHelperImpl() { | public ProjectHelperImpl() { | ||||
implicitTarget.setName(""); | implicitTarget.setName(""); | ||||
} | } | ||||
@@ -79,12 +79,14 @@ public class DefaultInputHandler implements InputHandler { | |||||
/** | /** | ||||
* Prompts and requests input. May loop until a valid input has | * Prompts and requests input. May loop until a valid input has | ||||
* been entered. | * been entered. | ||||
* @param request the request to handle | |||||
* @throws BuildException if not possible to read from console | |||||
*/ | */ | ||||
public void handleInput(InputRequest request) throws BuildException { | public void handleInput(InputRequest request) throws BuildException { | ||||
String prompt = getPrompt(request); | String prompt = getPrompt(request); | ||||
DataInputStream in = null; | DataInputStream in = null; | ||||
try { | try { | ||||
in = | |||||
in = | |||||
new DataInputStream(new KeepAliveInputStream(getInputStream())); | new DataInputStream(new KeepAliveInputStream(getInputStream())); | ||||
do { | do { | ||||
System.err.println(prompt); | System.err.println(prompt); | ||||
@@ -115,6 +117,7 @@ public class DefaultInputHandler implements InputHandler { | |||||
* | * | ||||
* @param request the request to construct the prompt for. | * @param request the request to construct the prompt for. | ||||
* Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
* @return the prompt to ask the user | |||||
*/ | */ | ||||
protected String getPrompt(InputRequest request) { | protected String getPrompt(InputRequest request) { | ||||
String prompt = request.getPrompt(); | String prompt = request.getPrompt(); | ||||
@@ -139,6 +142,7 @@ public class DefaultInputHandler implements InputHandler { | |||||
/** | /** | ||||
* Returns the input stream from which the user input should be read. | * Returns the input stream from which the user input should be read. | ||||
* @return the input stream from which the user input should be read. | |||||
*/ | */ | ||||
protected InputStream getInputStream() { | protected InputStream getInputStream() { | ||||
return System.in; | return System.in; | ||||
@@ -71,6 +71,8 @@ public interface InputHandler { | |||||
* | * | ||||
* <p>Postcondition: request.getInput will return a non-null | * <p>Postcondition: request.getInput will return a non-null | ||||
* value, request.isInputValid will return true.</p> | * value, request.isInputValid will return true.</p> | ||||
* @param request the request to be processed | |||||
* @throws org.apache.tools.ant.BuildException if the input cannot be read from the console | |||||
*/ | */ | ||||
void handleInput(InputRequest request) | void handleInput(InputRequest request) | ||||
throws org.apache.tools.ant.BuildException; | throws org.apache.tools.ant.BuildException; | ||||