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 &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
*/
public void setStubVersion(String stubVersion) {
@@ -583,84 +583,91 @@ public class Rmic extends MatchingTask {
*/
public void execute() throws BuildException {
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 {
cleanup();
}
@@ -686,7 +693,8 @@ public class Rmic extends MatchingTask {
*/
private void moveGeneratedFile(File baseDir, File sourceBaseFile, String classname,
RmicAdapter adapter) throws BuildException {
String classFileName = classname.replace('.', File.separatorChar) + ".class";
String classFileName = classname.replace('.', File.separatorChar)
+ ".class";
String[] generatedFiles = adapter.getMapper().mapFileName(classFileName);

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

File oldFile = new File(baseDir, sourceFileName);
if (!oldFile.exists()) {
@@ -707,14 +716,16 @@ public class Rmic extends MatchingTask {
File newFile = new File(sourceBaseFile, sourceFileName);
try {
if (filtering) {
FILE_UTILS.copyFile(oldFile, newFile, new FilterSetCollection(getProject()
.getGlobalFilterSet()));
FILE_UTILS.copyFile(oldFile, newFile,
new FilterSetCollection(getProject()
.getGlobalFilterSet()));
} else {
FILE_UTILS.copyFile(oldFile, newFile);
}
oldFile.delete();
} 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();
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.",
Project.MSG_VERBOSE);
} 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 {
SourceFileScanner sfs = new SourceFileScanner(this);
newFiles = sfs.restrict(files, baseDir, getOutputDir(), mapper);
@@ -760,12 +772,15 @@ public class Rmic extends MatchingTask {
}
return isValidRmiRemote(testClass);
} 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) {
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) {
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
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) {
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) {
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) {
throw new BuildException("No property defined");
@@ -128,39 +128,40 @@ public class WhichResource extends Task {
if (classpath != null) {
classpath = classpath.concatSystemClasspath("ignore");
getProject().log("using user supplied classpath: " + classpath,
Project.MSG_DEBUG);
Project.MSG_DEBUG);
} else {
classpath = new Path(getProject());
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;
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 {
if (loader != null) {
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.setParentFirst(false);
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) {
// How do we ever get here?
@@ -132,10 +132,12 @@ public class HasMethod extends ProjectComponent implements Condition {
}
}
} catch (ClassNotFoundException e) {
throw new BuildException("class \"" + classname + "\" was not found");
throw new BuildException("class \"" + classname
+ "\" was not found");
} 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;
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 {
if (preLoadClass != loader && loader != null) {
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 {
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 {
if (cl != null) {
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 =
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 =
new int[] {
1,
2,
3,
3,
};
1,
2,
3,
3,
};

protected static final String COM_PACKAGE = "COM.sun.labs.";
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
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;
}
cmdl.createArgument().setValue(targetFile.getAbsolutePath());
@@ -413,78 +415,77 @@ public class JavaCC extends Task {

AntClassLoader l = null;
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 {
javaccClass = ORG_PACKAGE_3_0 + ORG_JAVACC_CLASS;
javaccClass = ORG_PACKAGE_3_1 + ORG_JAVACC_CLASS;
is = l.getResourceAsStream(javaccClass.replace('.', '/')
+ ".class");
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 {
if (l != null) {
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() {
return compileList;
}
@@ -432,80 +432,87 @@ public class JspC extends MatchingTask {

if (!destDir.isDirectory()) {
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();

AntClassLoader al = null;
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 {
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 {
if (al != null) {
al.cleanup();
@@ -533,7 +540,7 @@ public class JspC extends MatchingTask {
* do the compile
*/
private void doCompilation(JspCompilerAdapter compiler)
throws BuildException {
throws BuildException {
// now we need to populate the compiler adapter
compiler.setJspc(this);

@@ -562,8 +569,8 @@ public class JspC extends MatchingTask {
* @param mangler the jsp filename mangler.
* @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();

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

if (srcFile.lastModified() > now) {
log("Warning: file modified in the future: " + filename,
Project.MSG_WARN);
Project.MSG_WARN);
}
boolean shouldCompile = false;
shouldCompile = isCompileNeeded(srcFile, javaFile);
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()
+ " because java file " + javaFile.getPath()
+ " 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 {
if (srcFile.lastModified() > javaFile.lastModified()) {
if (javaFile.length() == 0) {
shouldCompile = true;
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;
}
@@ -640,12 +647,13 @@ public class JspC extends MatchingTask {
* @return the filename.
* @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")) {
return null;
}
String javaFileName = mangler.mapJspToJavaName(srcFile);
// String srcFileDir=srcFile.getParent();
// String srcFileDir=srcFile.getParent();
return new File(dest, javaFileName);
}

@@ -692,9 +700,9 @@ public class JspC extends MatchingTask {
public void setBaseDir(File 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;
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 {
if (loader != null) {
loader.cleanup();


Loading…
Cancel
Save