Browse Source

whitespace

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@811656 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
65fc13760d
7 changed files with 356 additions and 326 deletions
  1. +96
    -81
      src/main/org/apache/tools/ant/taskdefs/Rmic.java
  2. +29
    -28
      src/main/org/apache/tools/ant/taskdefs/WhichResource.java
  3. +20
    -18
      src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
  4. +35
    -33
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  5. +66
    -65
      src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
  6. +88
    -80
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
  7. +22
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 96
- 81
src/main/org/apache/tools/ant/taskdefs/Rmic.java View File

@@ -220,7 +220,7 @@ public class Rmic extends MatchingTask {


/** /**
* Specify the JDK version for the generated stub code. * Specify the JDK version for the generated stub code.
* Specify &quot;1.1&quot; to pass the &quot;-v1.1&quot; option to rmic.</td>
* Specify &quot;1.1&quot; to pass the &quot;-v1.1&quot; option to rmic.
* @param stubVersion the JDK version * @param stubVersion the JDK version
*/ */
public void setStubVersion(String stubVersion) { public void setStubVersion(String stubVersion) {
@@ -583,84 +583,91 @@ public class Rmic extends MatchingTask {
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {
try { try {
compileList.clear();
compileList.clear();


File outputDir = getOutputDir();
if (outputDir == null) {
throw new BuildException(ERROR_BASE_NOT_SET, getLocation());
}
if (!outputDir.exists()) {
throw new BuildException(ERROR_NO_BASE_EXISTS + outputDir, getLocation());
}
if (!outputDir.isDirectory()) {
throw new BuildException(ERROR_NOT_A_DIR + outputDir, getLocation());
}
if (verify) {
log("Verify has been turned on.", Project.MSG_VERBOSE);
}
RmicAdapter adapter =
nestedAdapter != null ? nestedAdapter :
RmicAdapterFactory.getRmic(getCompiler(), this,
createCompilerClasspath());

// now we need to populate the compiler adapter
adapter.setRmic(this);

Path classpath = adapter.getClasspath();
loader = getProject().createClassLoader(classpath);

// scan base dirs to build up compile lists only if a
// specific classname is not given
if (classname == null) {
DirectoryScanner ds = this.getDirectoryScanner(baseDir);
String[] files = ds.getIncludedFiles();
scanDir(baseDir, files, adapter.getMapper());
} else {
// otherwise perform a timestamp comparison - at least
String path = classname.replace('.', File.separatorChar) + ".class";
File f = new File(baseDir, path);
if (f.isFile()) {
scanDir(baseDir, new String[] {path}, adapter.getMapper());
} else {
// Does not exist, so checking whether it is up to date makes no sense.
// Compilation will fail later anyway, but tests expect a certain output.
compileList.add(classname);
File outputDir = getOutputDir();
if (outputDir == null) {
throw new BuildException(ERROR_BASE_NOT_SET, getLocation());
} }
}
int fileCount = compileList.size();
if (fileCount > 0) {
log("RMI Compiling " + fileCount + " class"
+ (fileCount > 1 ? "es" : "") + " to "
+ outputDir, Project.MSG_INFO);

if (listFiles) {
for (int i = 0; i < fileCount; i++) {
log(compileList.get(i).toString());
if (!outputDir.exists()) {
throw new BuildException(ERROR_NO_BASE_EXISTS + outputDir,
getLocation());
}
if (!outputDir.isDirectory()) {
throw new BuildException(ERROR_NOT_A_DIR + outputDir, getLocation());
}
if (verify) {
log("Verify has been turned on.", Project.MSG_VERBOSE);
}
RmicAdapter adapter =
nestedAdapter != null ? nestedAdapter :
RmicAdapterFactory.getRmic(getCompiler(), this,
createCompilerClasspath());

// now we need to populate the compiler adapter
adapter.setRmic(this);

Path classpath = adapter.getClasspath();
loader = getProject().createClassLoader(classpath);

// scan base dirs to build up compile lists only if a
// specific classname is not given
if (classname == null) {
DirectoryScanner ds = this.getDirectoryScanner(baseDir);
String[] files = ds.getIncludedFiles();
scanDir(baseDir, files, adapter.getMapper());
} else {
// otherwise perform a timestamp comparison - at least
String path = classname.replace('.', File.separatorChar)
+ ".class";
File f = new File(baseDir, path);
if (f.isFile()) {
scanDir(baseDir, new String[] {path}, adapter.getMapper());
} else {
// Does not exist, so checking whether it is up to
// date makes no sense. Compilation will fail
// later anyway, but tests expect a certain
// output.
compileList.add(classname);
} }
} }
int fileCount = compileList.size();
if (fileCount > 0) {
log("RMI Compiling " + fileCount + " class"
+ (fileCount > 1 ? "es" : "") + " to "
+ outputDir, Project.MSG_INFO);

if (listFiles) {
for (int i = 0; i < fileCount; i++) {
log(compileList.get(i).toString());
}
}


// finally, lets execute the compiler!!
if (!adapter.execute()) {
throw new BuildException(ERROR_RMIC_FAILED, getLocation());
// finally, lets execute the compiler!!
if (!adapter.execute()) {
throw new BuildException(ERROR_RMIC_FAILED, getLocation());
}
} }
}
/*
* Move the generated source file to the base directory. If
* base directory and sourcebase are the same, the generated
* sources are already in place.
*/
if (null != sourceBase && !outputDir.equals(sourceBase)
&& fileCount > 0) {
if (idl) {
log("Cannot determine sourcefiles in idl mode, ", Project.MSG_WARN);
log("sourcebase attribute will be ignored.", Project.MSG_WARN);
} else {
for (int j = 0; j < fileCount; j++) {
moveGeneratedFile(outputDir, sourceBase, (String) compileList.elementAt(j),
adapter);
/*
* Move the generated source file to the base directory. If
* base directory and sourcebase are the same, the generated
* sources are already in place.
*/
if (null != sourceBase && !outputDir.equals(sourceBase)
&& fileCount > 0) {
if (idl) {
log("Cannot determine sourcefiles in idl mode, ",
Project.MSG_WARN);
log("sourcebase attribute will be ignored.",
Project.MSG_WARN);
} else {
for (int j = 0; j < fileCount; j++) {
moveGeneratedFile(outputDir, sourceBase,
(String) compileList.elementAt(j),
adapter);
}
} }
} }
}
} finally { } finally {
cleanup(); cleanup();
} }
@@ -686,7 +693,8 @@ public class Rmic extends MatchingTask {
*/ */
private void moveGeneratedFile(File baseDir, File sourceBaseFile, String classname, private void moveGeneratedFile(File baseDir, File sourceBaseFile, String classname,
RmicAdapter adapter) throws BuildException { RmicAdapter adapter) throws BuildException {
String classFileName = classname.replace('.', File.separatorChar) + ".class";
String classFileName = classname.replace('.', File.separatorChar)
+ ".class";
String[] generatedFiles = adapter.getMapper().mapFileName(classFileName); String[] generatedFiles = adapter.getMapper().mapFileName(classFileName);


for (int i = 0; i < generatedFiles.length; i++) { for (int i = 0; i < generatedFiles.length; i++) {
@@ -696,7 +704,8 @@ public class Rmic extends MatchingTask {
// have a corresponding Java source for example. // have a corresponding Java source for example.
continue; continue;
} }
String sourceFileName = StringUtils.removeSuffix(generatedFile, ".class");
String sourceFileName = StringUtils.removeSuffix(generatedFile,
".class");


File oldFile = new File(baseDir, sourceFileName); File oldFile = new File(baseDir, sourceFileName);
if (!oldFile.exists()) { if (!oldFile.exists()) {
@@ -707,14 +716,16 @@ public class Rmic extends MatchingTask {
File newFile = new File(sourceBaseFile, sourceFileName); File newFile = new File(sourceBaseFile, sourceFileName);
try { try {
if (filtering) { if (filtering) {
FILE_UTILS.copyFile(oldFile, newFile, new FilterSetCollection(getProject()
.getGlobalFilterSet()));
FILE_UTILS.copyFile(oldFile, newFile,
new FilterSetCollection(getProject()
.getGlobalFilterSet()));
} else { } else {
FILE_UTILS.copyFile(oldFile, newFile); FILE_UTILS.copyFile(oldFile, newFile);
} }
oldFile.delete(); oldFile.delete();
} catch (IOException ioe) { } catch (IOException ioe) {
String msg = "Failed to copy " + oldFile + " to " + newFile + " due to "
String msg = "Failed to copy " + oldFile + " to " + newFile
+ " due to "
+ ioe.getMessage(); + ioe.getMessage();
throw new BuildException(msg, ioe, getLocation()); throw new BuildException(msg, ioe, getLocation());
} }
@@ -734,7 +745,8 @@ public class Rmic extends MatchingTask {
log("will leave uptodate test to rmic implementation in idl mode.", log("will leave uptodate test to rmic implementation in idl mode.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} else if (iiop && iiopOpts != null && iiopOpts.indexOf("-always") > -1) { } else if (iiop && iiopOpts != null && iiopOpts.indexOf("-always") > -1) {
log("no uptodate test as -always option has been specified", Project.MSG_VERBOSE);
log("no uptodate test as -always option has been specified",
Project.MSG_VERBOSE);
} else { } else {
SourceFileScanner sfs = new SourceFileScanner(this); SourceFileScanner sfs = new SourceFileScanner(this);
newFiles = sfs.restrict(files, baseDir, getOutputDir(), mapper); newFiles = sfs.restrict(files, baseDir, getOutputDir(), mapper);
@@ -760,12 +772,15 @@ public class Rmic extends MatchingTask {
} }
return isValidRmiRemote(testClass); return isValidRmiRemote(testClass);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname + ERROR_NOT_FOUND, Project.MSG_WARN);
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname + ERROR_NOT_FOUND,
Project.MSG_WARN);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname + ERROR_NOT_DEFINED, Project.MSG_WARN);
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname + ERROR_NOT_DEFINED,
Project.MSG_WARN);
} catch (Throwable t) { } catch (Throwable t) {
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname + ERROR_LOADING_CAUSED_EXCEPTION
+ t.getMessage(), Project.MSG_WARN);
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname
+ ERROR_LOADING_CAUSED_EXCEPTION + t.getMessage(),
Project.MSG_WARN);
} }
// we only get here if an exception has been thrown // we only get here if an exception has been thrown
return false; return false;


+ 29
- 28
src/main/org/apache/tools/ant/taskdefs/WhichResource.java View File

@@ -107,12 +107,12 @@ public class WhichResource extends Task {




if (setcount == 0) { if (setcount == 0) {
throw new BuildException(
"One of classname or resource must be specified");
throw new BuildException("One of classname or resource must"
+ " be specified");
} }
if (setcount > 1) { if (setcount > 1) {
throw new BuildException(
"Only one of classname or resource can be specified");
throw new BuildException("Only one of classname or resource can"
+ " be specified");
} }
if (property == null) { if (property == null) {
throw new BuildException("No property defined"); throw new BuildException("No property defined");
@@ -128,39 +128,40 @@ public class WhichResource extends Task {
if (classpath != null) { if (classpath != null) {
classpath = classpath.concatSystemClasspath("ignore"); classpath = classpath.concatSystemClasspath("ignore");
getProject().log("using user supplied classpath: " + classpath, getProject().log("using user supplied classpath: " + classpath,
Project.MSG_DEBUG);
Project.MSG_DEBUG);
} else { } else {
classpath = new Path(getProject()); classpath = new Path(getProject());
classpath = classpath.concatSystemClasspath("only"); classpath = classpath.concatSystemClasspath("only");
getProject().log("using system classpath: " + classpath, Project.MSG_DEBUG);
getProject().log("using system classpath: " + classpath,
Project.MSG_DEBUG);
} }
AntClassLoader loader = null; AntClassLoader loader = null;
try { try {
loader = AntClassLoader.newAntClassLoader(getProject().getCoreLoader(),
getProject(),
classpath, false);
String loc = null;
if (classname != null) {
//convert a class name into a resource
resource = classname.replace('.', '/') + ".class";
}
loader = AntClassLoader.newAntClassLoader(getProject().getCoreLoader(),
getProject(),
classpath, false);
String loc = null;
if (classname != null) {
//convert a class name into a resource
resource = classname.replace('.', '/') + ".class";
}


if (resource == null) {
throw new BuildException("One of class or resource is required");
}
if (resource == null) {
throw new BuildException("One of class or resource is required");
}


if (resource.startsWith("/")) {
resource = resource.substring(1);
}
if (resource.startsWith("/")) {
resource = resource.substring(1);
}


log("Searching for " + resource, Project.MSG_VERBOSE);
URL url;
url = loader.getResource(resource);
if (url != null) {
//set the property
loc = url.toExternalForm();
getProject().setNewProperty(property, loc);
}
log("Searching for " + resource, Project.MSG_VERBOSE);
URL url;
url = loader.getResource(resource);
if (url != null) {
//set the property
loc = url.toExternalForm();
getProject().setNewProperty(property, loc);
}
} finally { } finally {
if (loader != null) { if (loader != null) {
loader.cleanup(); loader.cleanup();


+ 20
- 18
src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java View File

@@ -110,13 +110,13 @@ public class HasMethod extends ProjectComponent implements Condition {
loader = getProject().createClassLoader(classpath); loader = getProject().createClassLoader(classpath);
loader.setParentFirst(false); loader.setParentFirst(false);
loader.addJavaLibraries(); loader.addJavaLibraries();
try {
return loader.findClass(classname);
} catch (SecurityException se) {
// class found but restricted name; this is
// actually the case we're looking for in JDK 1.3+,
// so catch the exception and return
return null;
try {
return loader.findClass(classname);
} catch (SecurityException se) {
// class found but restricted name; this is
// actually the case we're looking for in JDK 1.3+,
// so catch the exception and return
return null;
} }
} else if (loader != null) { } else if (loader != null) {
// How do we ever get here? // How do we ever get here?
@@ -132,10 +132,12 @@ public class HasMethod extends ProjectComponent implements Condition {
} }
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new BuildException("class \"" + classname + "\" was not found");
throw new BuildException("class \"" + classname
+ "\" was not found");
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw new BuildException("Could not load dependent class \"" + e.getMessage()
+ "\" for class \"" + classname + "\"");
throw new BuildException("Could not load dependent class \""
+ e.getMessage()
+ "\" for class \"" + classname + "\"");
} }
} }


@@ -147,14 +149,14 @@ public class HasMethod extends ProjectComponent implements Condition {
} }
ClassLoader preLoadClass = loader; ClassLoader preLoadClass = loader;
try { try {
Class clazz = loadClass(classname);
if (method != null) {
return isMethodFound(clazz);
}
if (field != null) {
return isFieldFound(clazz);
}
throw new BuildException("Neither method nor field defined");
Class clazz = loadClass(classname);
if (method != null) {
return isMethodFound(clazz);
}
if (field != null) {
return isFieldFound(clazz);
}
throw new BuildException("Neither method nor field defined");
} finally { } finally {
if (preLoadClass != loader && loader != null) { if (preLoadClass != loader && loader != null) {
loader.cleanup(); loader.cleanup();


+ 35
- 33
src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java View File

@@ -684,41 +684,43 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
try { try {
cl = classpath.getProject().createClassLoader(classpath); cl = classpath.getProject().createClassLoader(classpath);


try {
cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.GENIC_CLASS;
} catch (ClassNotFoundException cnf1) {
log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ "' not found in classpath.",
Project.MSG_VERBOSE);
}
try {
cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.GENIC_CLASS;
} catch (ClassNotFoundException cnf1) {
log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ "' not found in classpath.",
Project.MSG_VERBOSE);
}


try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_1;

} catch (ClassNotFoundException cnf2) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
+ "' not found in classpath.",
Project.MSG_VERBOSE);
}
try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
log("Found GenIC class '"
+ JonasDeploymentTool.OLD_GENIC_CLASS_1
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_1;


try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_2;

} catch (ClassNotFoundException cnf3) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
+ "' not found in classpath.",
Project.MSG_VERBOSE);
}
} catch (ClassNotFoundException cnf2) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
+ "' not found in classpath.",
Project.MSG_VERBOSE);
}

try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
log("Found GenIC class '"
+ JonasDeploymentTool.OLD_GENIC_CLASS_2
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_2;

} catch (ClassNotFoundException cnf3) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
+ "' not found in classpath.",
Project.MSG_VERBOSE);
}
} finally { } finally {
if (cl != null) { if (cl != null) {
cl.cleanup(); cl.cleanup();


+ 66
- 65
src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java View File

@@ -79,19 +79,19 @@ public class JavaCC extends Task {


protected static final String[] ARCHIVE_LOCATIONS = protected static final String[] ARCHIVE_LOCATIONS =
new String[] { new String[] {
"JavaCC.zip",
"bin/lib/JavaCC.zip",
"bin/lib/javacc.jar",
"javacc.jar", // used by jpackage for JavaCC 3.x
};
"JavaCC.zip",
"bin/lib/JavaCC.zip",
"bin/lib/javacc.jar",
"javacc.jar", // used by jpackage for JavaCC 3.x
};


protected static final int[] ARCHIVE_LOCATIONS_VS_MAJOR_VERSION = protected static final int[] ARCHIVE_LOCATIONS_VS_MAJOR_VERSION =
new int[] { new int[] {
1,
2,
3,
3,
};
1,
2,
3,
3,
};


protected static final String COM_PACKAGE = "COM.sun.labs."; protected static final String COM_PACKAGE = "COM.sun.labs.";
protected static final String COM_JAVACC_CLASS = "javacc.Main"; protected static final String COM_JAVACC_CLASS = "javacc.Main";
@@ -345,8 +345,10 @@ public class JavaCC extends Task {


// determine if the generated java file is up-to-date // determine if the generated java file is up-to-date
final File javaFile = getOutputJavaFile(outputDirectory, targetFile); final File javaFile = getOutputJavaFile(outputDirectory, targetFile);
if (javaFile.exists() && targetFile.lastModified() < javaFile.lastModified()) {
log("Target is already built - skipping (" + targetFile + ")", Project.MSG_VERBOSE);
if (javaFile.exists()
&& targetFile.lastModified() < javaFile.lastModified()) {
log("Target is already built - skipping (" + targetFile + ")",
Project.MSG_VERBOSE);
return; return;
} }
cmdl.createArgument().setValue(targetFile.getAbsolutePath()); cmdl.createArgument().setValue(targetFile.getAbsolutePath());
@@ -413,78 +415,77 @@ public class JavaCC extends Task {


AntClassLoader l = null; AntClassLoader l = null;
try { try {
l =
AntClassLoader.newAntClassLoader(null, null,
path
.concatSystemClasspath("ignore"),
true);
String javaccClass = COM_PACKAGE + COM_JAVACC_CLASS;
InputStream is = l.getResourceAsStream(javaccClass.replace('.', '/')
+ ".class");
if (is != null) {
packagePrefix = COM_PACKAGE;
switch (type) {
case TASKDEF_TYPE_JAVACC:
mainClass = COM_JAVACC_CLASS;
l = AntClassLoader.newAntClassLoader(null, null,
path
.concatSystemClasspath("ignore"),
true);
String javaccClass = COM_PACKAGE + COM_JAVACC_CLASS;
InputStream is = l.getResourceAsStream(javaccClass.replace('.', '/')
+ ".class");
if (is != null) {
packagePrefix = COM_PACKAGE;
switch (type) {
case TASKDEF_TYPE_JAVACC:
mainClass = COM_JAVACC_CLASS;


break;
break;


case TASKDEF_TYPE_JJTREE:
mainClass = COM_JJTREE_CLASS;
case TASKDEF_TYPE_JJTREE:
mainClass = COM_JJTREE_CLASS;


break;
break;


case TASKDEF_TYPE_JJDOC:
mainClass = COM_JJDOC_CLASS;
case TASKDEF_TYPE_JJDOC:
mainClass = COM_JJDOC_CLASS;


break;
default:
// Fall Through
}
} else {
javaccClass = ORG_PACKAGE_3_1 + ORG_JAVACC_CLASS;
is = l.getResourceAsStream(javaccClass.replace('.', '/')
+ ".class");
if (is != null) {
packagePrefix = ORG_PACKAGE_3_1;
break;
default:
// Fall Through
}
} else { } else {
javaccClass = ORG_PACKAGE_3_0 + ORG_JAVACC_CLASS;
javaccClass = ORG_PACKAGE_3_1 + ORG_JAVACC_CLASS;
is = l.getResourceAsStream(javaccClass.replace('.', '/') is = l.getResourceAsStream(javaccClass.replace('.', '/')
+ ".class"); + ".class");
if (is != null) { if (is != null) {
packagePrefix = ORG_PACKAGE_3_0;
packagePrefix = ORG_PACKAGE_3_1;
} else {
javaccClass = ORG_PACKAGE_3_0 + ORG_JAVACC_CLASS;
is = l.getResourceAsStream(javaccClass.replace('.', '/')
+ ".class");
if (is != null) {
packagePrefix = ORG_PACKAGE_3_0;
}
} }
}


if (is != null) {
switch (type) {
case TASKDEF_TYPE_JAVACC:
mainClass = ORG_JAVACC_CLASS;
if (is != null) {
switch (type) {
case TASKDEF_TYPE_JAVACC:
mainClass = ORG_JAVACC_CLASS;


break;
break;


case TASKDEF_TYPE_JJTREE:
mainClass = ORG_JJTREE_CLASS;
case TASKDEF_TYPE_JJTREE:
mainClass = ORG_JJTREE_CLASS;


break;
break;


case TASKDEF_TYPE_JJDOC:
mainClass = ORG_JJDOC_CLASS;
case TASKDEF_TYPE_JJDOC:
mainClass = ORG_JJDOC_CLASS;


break;
default:
// Fall Through
break;
default:
// Fall Through
}
} }
} }
}


if (packagePrefix == null) {
throw new BuildException("failed to load JavaCC");
}
if (mainClass == null) {
throw new BuildException("unknown task type " + type);
}
return packagePrefix + mainClass;
if (packagePrefix == null) {
throw new BuildException("failed to load JavaCC");
}
if (mainClass == null) {
throw new BuildException("unknown task type " + type);
}
return packagePrefix + mainClass;
} finally { } finally {
if (l != null) { if (l != null) {
l.cleanup(); l.cleanup();


+ 88
- 80
src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java View File

@@ -409,9 +409,9 @@ public class JspC extends MatchingTask {
} }


/** /**
* get the list of files to compile
* @return the list of files.
*/
* get the list of files to compile
* @return the list of files.
*/
public Vector getCompileList() { public Vector getCompileList() {
return compileList; return compileList;
} }
@@ -432,80 +432,87 @@ public class JspC extends MatchingTask {


if (!destDir.isDirectory()) { if (!destDir.isDirectory()) {
throw new BuildException("destination directory \"" + destDir throw new BuildException("destination directory \"" + destDir
+ "\" does not exist or is not a directory", getLocation());
+ "\" does not exist or is not a directory",
getLocation());
} }


File dest = getActualDestDir(); File dest = getActualDestDir();


AntClassLoader al = null; AntClassLoader al = null;
try { try {
//bind to a compiler
JspCompilerAdapter compiler =
JspCompilerAdapterFactory.getCompiler(compilerName, this,
al = getProject().createClassLoader(compilerClasspath));

//if we are a webapp, hand off to the compiler, which had better handle it
if (webApp != null) {
doCompilation(compiler);
return;
}
//bind to a compiler
JspCompilerAdapter compiler =
JspCompilerAdapterFactory
.getCompiler(compilerName, this,
al = getProject().createClassLoader(compilerClasspath));

//if we are a webapp, hand off to the compiler, which had
//better handle it
if (webApp != null) {
doCompilation(compiler);
return;
}


// make sure that we've got a srcdir
if (src == null) {
throw new BuildException("srcdir attribute must be set!",
getLocation());
}
String [] list = src.list();
if (list.length == 0) {
throw new BuildException("srcdir attribute must be set!",
getLocation());
}
// make sure that we've got a srcdir
if (src == null) {
throw new BuildException("srcdir attribute must be set!",
getLocation());
}
String [] list = src.list();
if (list.length == 0) {
throw new BuildException("srcdir attribute must be set!",
getLocation());
}




// if the compiler does its own dependency stuff, we just call it right now
if (compiler.implementsOwnDependencyChecking()) {
doCompilation(compiler);
return;
}
// if the compiler does its own dependency stuff, we just
// call it right now
if (compiler.implementsOwnDependencyChecking()) {
doCompilation(compiler);
return;
}


//the remainder of this method is only for compilers that need their dependency work done
JspMangler mangler = compiler.createMangler();

// scan source directories and dest directory to build up both copy
// lists and compile lists
resetFileLists();
int filecount = 0;
for (int i = 0; i < list.length; i++) {
File srcDir = getProject().resolveFile(list[i]);
if (!srcDir.exists()) {
throw new BuildException("srcdir \"" + srcDir.getPath()
+ "\" does not exist!", getLocation());
//the remainder of this method is only for compilers that
//need their dependency work done
JspMangler mangler = compiler.createMangler();

// scan source directories and dest directory to build up both copy
// lists and compile lists
resetFileLists();
int filecount = 0;
for (int i = 0; i < list.length; i++) {
File srcDir = getProject().resolveFile(list[i]);
if (!srcDir.exists()) {
throw new BuildException("srcdir \"" + srcDir.getPath()
+ "\" does not exist!",
getLocation());
}
DirectoryScanner ds = this.getDirectoryScanner(srcDir);
String[] files = ds.getIncludedFiles();
filecount = files.length;
scanDir(srcDir, dest, mangler, files);
} }
DirectoryScanner ds = this.getDirectoryScanner(srcDir);
String[] files = ds.getIncludedFiles();
filecount = files.length;
scanDir(srcDir, dest, mangler, files);
}


// compile the source files
// compile the source files


log("compiling " + compileList.size() + " files", Project.MSG_VERBOSE);
log("compiling " + compileList.size() + " files",
Project.MSG_VERBOSE);


if (compileList.size() > 0) {
if (compileList.size() > 0) {


log("Compiling " + compileList.size() + " source file"
+ (compileList.size() == 1 ? "" : "s")
+ " to "
+ dest);
doCompilation(compiler);
log("Compiling " + compileList.size() + " source file"
+ (compileList.size() == 1 ? "" : "s")
+ " to "
+ dest);
doCompilation(compiler);


} else {
if (filecount == 0) {
log("there were no files to compile", Project.MSG_INFO);
} else { } else {
log("all files are up to date", Project.MSG_VERBOSE);
if (filecount == 0) {
log("there were no files to compile", Project.MSG_INFO);
} else {
log("all files are up to date", Project.MSG_VERBOSE);
}
} }
}
} finally { } finally {
if (al != null) { if (al != null) {
al.cleanup(); al.cleanup();
@@ -533,7 +540,7 @@ public class JspC extends MatchingTask {
* do the compile * do the compile
*/ */
private void doCompilation(JspCompilerAdapter compiler) private void doCompilation(JspCompilerAdapter compiler)
throws BuildException {
throws BuildException {
// now we need to populate the compiler adapter // now we need to populate the compiler adapter
compiler.setJspc(this); compiler.setJspc(this);


@@ -562,8 +569,8 @@ public class JspC extends MatchingTask {
* @param mangler the jsp filename mangler. * @param mangler the jsp filename mangler.
* @param files the file names to mangle. * @param files the file names to mangle.
*/ */
protected void scanDir(
File srcDir, File dest, JspMangler mangler, String[] files) {
protected void scanDir(File srcDir, File dest, JspMangler mangler,
String[] files) {


long now = (new Date()).getTime(); long now = (new Date()).getTime();


@@ -577,13 +584,13 @@ public class JspC extends MatchingTask {


if (srcFile.lastModified() > now) { if (srcFile.lastModified() > now) {
log("Warning: file modified in the future: " + filename, log("Warning: file modified in the future: " + filename,
Project.MSG_WARN);
Project.MSG_WARN);
} }
boolean shouldCompile = false; boolean shouldCompile = false;
shouldCompile = isCompileNeeded(srcFile, javaFile); shouldCompile = isCompileNeeded(srcFile, javaFile);
if (shouldCompile) { if (shouldCompile) {
compileList.addElement(srcFile.getAbsolutePath());
javaFiles.addElement(javaFile);
compileList.addElement(srcFile.getAbsolutePath());
javaFiles.addElement(javaFile);
} }
} }
} }
@@ -611,21 +618,21 @@ public class JspC extends MatchingTask {
log("Compiling " + srcFile.getPath() log("Compiling " + srcFile.getPath()
+ " because java file " + javaFile.getPath() + " because java file " + javaFile.getPath()
+ " does not exist", Project.MSG_VERBOSE); + " does not exist", Project.MSG_VERBOSE);
} else {
if (srcFile.lastModified() > javaFile.lastModified()) {
shouldCompile = true;
log("Compiling " + srcFile.getPath()
+ " because it is out of date with respect to "
+ javaFile.getPath(),
Project.MSG_VERBOSE);
} else { } else {
if (srcFile.lastModified() > javaFile.lastModified()) {
if (javaFile.length() == 0) {
shouldCompile = true; shouldCompile = true;
log("Compiling " + srcFile.getPath() log("Compiling " + srcFile.getPath()
+ " because it is out of date with respect to "
+ javaFile.getPath(),
Project.MSG_VERBOSE);
} else {
if (javaFile.length() == 0) {
shouldCompile = true;
log("Compiling " + srcFile.getPath()
+ " because java file " + javaFile.getPath()
+ " is empty", Project.MSG_VERBOSE);
}
+ " because java file " + javaFile.getPath()
+ " is empty", Project.MSG_VERBOSE);
} }
}
} }
return shouldCompile; return shouldCompile;
} }
@@ -640,12 +647,13 @@ public class JspC extends MatchingTask {
* @return the filename. * @return the filename.
* @todo support packages and subdirs * @todo support packages and subdirs
*/ */
protected File mapToJavaFile(JspMangler mangler, File srcFile, File srcDir, File dest) {
protected File mapToJavaFile(JspMangler mangler, File srcFile, File srcDir,
File dest) {
if (!srcFile.getName().endsWith(".jsp")) { if (!srcFile.getName().endsWith(".jsp")) {
return null; return null;
} }
String javaFileName = mangler.mapJspToJavaName(srcFile); String javaFileName = mangler.mapJspToJavaName(srcFile);
// String srcFileDir=srcFile.getParent();
// String srcFileDir=srcFile.getParent();
return new File(dest, javaFileName); return new File(dest, javaFileName);
} }


@@ -692,9 +700,9 @@ public class JspC extends MatchingTask {
public void setBaseDir(File directory) { public void setBaseDir(File directory) {
this.directory = directory; this.directory = directory;
} }
//end inner class
//end inner class
} }




//end class
//end class
} }

+ 22
- 21
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -1110,29 +1110,30 @@ public class JUnitTask extends Task {
} }
AntClassLoader loader = null; AntClassLoader loader = null;
try { try {
loader = AntClassLoader.newAntClassLoader(null,
getProject(), cmd.createClasspath(getProject()),
true);
String projectResourceName = LoaderUtils.classNameToResource(
Project.class.getName());
URL previous = null;
try {
for (Enumeration e = loader.getResources(projectResourceName);
e.hasMoreElements();) {
URL current = (URL) e.nextElement();
if (previous != null && !current.equals(previous)) {
log("WARNING: multiple versions of ant detected "
+ "in path for junit "
+ LINE_SEP + " " + previous
+ LINE_SEP + " and " + current,
Project.MSG_WARN);
return;
loader =
AntClassLoader.newAntClassLoader(null, getProject(),
cmd.createClasspath(getProject()),
true);
String projectResourceName =
LoaderUtils.classNameToResource(Project.class.getName());
URL previous = null;
try {
for (Enumeration e = loader.getResources(projectResourceName);
e.hasMoreElements();) {
URL current = (URL) e.nextElement();
if (previous != null && !current.equals(previous)) {
log("WARNING: multiple versions of ant detected "
+ "in path for junit "
+ LINE_SEP + " " + previous
+ LINE_SEP + " and " + current,
Project.MSG_WARN);
return;
}
previous = current;
} }
previous = current;
} catch (Exception ex) {
// Ignore exception
} }
} catch (Exception ex) {
// Ignore exception
}
} finally { } finally {
if (loader != null) { if (loader != null) {
loader.cleanup(); loader.cleanup();


Loading…
Cancel
Save