Browse Source

reduce method length

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@566990 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
3ef74849ef
2 changed files with 68 additions and 53 deletions
  1. +30
    -26
      src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
  2. +38
    -27
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 30
- 26
src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java View File

@@ -131,6 +131,36 @@ public class Jikes extends DefaultCompilerAdapter {
cmd.createArgument().setValue(target);
}

addPropertyParams(cmd);

if (attributes.getSource() != null) {
cmd.createArgument().setValue("-source");
String source = attributes.getSource();
if (source.equals("1.1") || source.equals("1.2")) {
// support for -source 1.1 and -source 1.2 has been
// added with JDK 1.4.2, Jikes doesn't like it
attributes.log("Jikes doesn't support '-source " + source
+ "', will use '-source 1.3' instead");
cmd.createArgument().setValue("1.3");
} else {
cmd.createArgument().setValue(source);
}
}
addCurrentCompilerArgs(cmd);

int firstFileName = cmd.size();

Path boot = getBootClassPath();
if (boot.size() > 0) {
cmd.createArgument().setValue("-bootclasspath");
cmd.createArgument().setPath(boot);
}
logAndAddFilesToCompile(cmd);

return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
}

private void addPropertyParams(Commandline cmd) {
/**
* XXX
* Perhaps we shouldn't use properties for these
@@ -186,32 +216,6 @@ public class Jikes extends DefaultCompilerAdapter {
&& Project.toBoolean(fullDependProperty)) {
cmd.createArgument().setValue("+F");
}

if (attributes.getSource() != null) {
cmd.createArgument().setValue("-source");
String source = attributes.getSource();
if (source.equals("1.1") || source.equals("1.2")) {
// support for -source 1.1 and -source 1.2 has been
// added with JDK 1.4.2, Jikes doesn't like it
attributes.log("Jikes doesn't support '-source " + source
+ "', will use '-source 1.3' instead");
cmd.createArgument().setValue("1.3");
} else {
cmd.createArgument().setValue(source);
}
}
addCurrentCompilerArgs(cmd);

int firstFileName = cmd.size();

Path boot = getBootClassPath();
if (boot.size() > 0) {
cmd.createArgument().setValue("-bootclasspath");
cmd.createArgument().setPath(boot);
}
logAndAddFilesToCompile(cmd);

return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
}

}

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

@@ -926,34 +926,9 @@ public class JUnitTask extends Task {
cmd.createArgument().setValue(Constants.HALT_ON_ERROR + test.getHaltonerror());
cmd.createArgument().setValue(Constants.HALT_ON_FAILURE
+ test.getHaltonfailure());
if (includeAntRuntime) {
Vector v = Execute.getProcEnvironment();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
String s = (String) e.nextElement();
if (s.startsWith(CLASSPATH)) {
cmd.createClasspath(getProject()).createPath()
.append(new Path(getProject(),
s.substring(CLASSPATH.length()
)));
}
}
log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
Project.MSG_VERBOSE);
cmd.createClasspath(getProject()).createPath()
.append(antRuntimeClasses);
}
checkIncludeAntRuntime(cmd);

if (summary) {
String prefix = "";
if ("withoutanderr".equalsIgnoreCase(summaryValue)) {
prefix = "OutErr";
}
cmd.createArgument()
.setValue(Constants.FORMATTER
+ "org.apache.tools.ant.taskdefs.optional.junit."
+ prefix + "SummaryJUnitResultFormatter");
}
checkIncludeSummary(cmd);

cmd.createArgument().setValue(Constants.SHOWOUTPUT
+ String.valueOf(showOutput));
@@ -1072,6 +1047,42 @@ public class JUnitTask extends Task {
return result;
}

/**
* Adding ant runtime.
*/
private void checkIncludeAntRuntime(CommandlineJava cmd) {
if (includeAntRuntime) {
Vector v = Execute.getProcEnvironment();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
String s = (String) e.nextElement();
if (s.startsWith(CLASSPATH)) {
cmd.createClasspath(getProject()).createPath()
.append(new Path(getProject(),
s.substring(CLASSPATH.length()
)));
}
}
log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
Project.MSG_VERBOSE);
cmd.createClasspath(getProject()).createPath()
.append(antRuntimeClasses);
}
}

private void checkIncludeSummary(CommandlineJava cmd) {
if (summary) {
String prefix = "";
if ("withoutanderr".equalsIgnoreCase(summaryValue)) {
prefix = "OutErr";
}
cmd.createArgument()
.setValue(Constants.FORMATTER
+ "org.apache.tools.ant.taskdefs.optional.junit."
+ prefix + "SummaryJUnitResultFormatter");
}
}

/**
* Check the path for multiple different versions of
* ant.


Loading…
Cancel
Save