diff options
author | Philipe Mulet | 2001-07-09 13:36:26 +0000 |
---|---|---|
committer | Philipe Mulet | 2001-07-09 13:36:26 +0000 |
commit | 51b5a3a2fd75c9aa227eb901c5d0dde418b20656 (patch) | |
tree | 627b34597fa3748c1de86b8bb86a8fc317ffacae | |
parent | c96aeb71dd443bf627a83c227410f17017e1091f (diff) | |
download | eclipse.jdt.core-51b5a3a2fd75c9aa227eb901c5d0dde418b20656.tar.gz eclipse.jdt.core-51b5a3a2fd75c9aa227eb901c5d0dde418b20656.tar.xz eclipse.jdt.core-51b5a3a2fd75c9aa227eb901c5d0dde418b20656.zip |
*** empty log message ***
3 files changed, 386 insertions, 50 deletions
diff --git a/org.eclipse.jdt.core/ant/org/eclipse/jdt/core/ant/Jdtcom.java b/org.eclipse.jdt.core/ant/org/eclipse/jdt/core/ant/Jdtcom.java new file mode 100644 index 0000000000..5486242bc8 --- /dev/null +++ b/org.eclipse.jdt.core/ant/org/eclipse/jdt/core/ant/Jdtcom.java @@ -0,0 +1,195 @@ +package org.eclipse.jdt.core.ant;
+
+import java.util.*;
+import java.io.*;
+
+import org.apache.tools.ant.*;
+import org.apache.tools.ant.taskdefs.*;
+import org.apache.tools.ant.types.*;
+import org.eclipse.jdt.internal.compiler.batch.Main;
+import org.eclipse.jdt.internal.core.ant.AntPrintWriter;
+
+public class Jdtcom extends MatchingTask {
+ private Path src;
+ private Path classpath;
+ private File dest;
+
+ private StringBuffer arguments;
+
+ public Jdtcom(){
+ arguments = new StringBuffer();
+ }
+
+ public void execute() throws BuildException {
+ if(src == null)
+ throw new BuildException("no");
+ if(dest == null)
+ throw new BuildException("no");
+
+ arguments.append(" -d "/*nonNLS*/);
+ arguments.append(dest.getAbsolutePath());
+
+ if(classpath != null){
+ arguments.append(" -classpath "/*nonNLS*/);
+ String[] classpathList = classpath.list();
+ for(int i = 0 ; i < classpathList.length ; i++){
+ File pathElement = project.resolveFile(classpathList[i]);
+ if(!pathElement.exists())
+ throw new BuildException("no");
+ if(i != 0)
+ arguments.append(";"/*nonNLS*/);
+ arguments.append(pathElement);
+ }
+ }
+
+ String[] srcList = src.list();
+ for(int i = 0 ; i < srcList.length ; i++){
+ File file = project.resolveFile(srcList[i]);
+ if(!file.exists())
+ throw new BuildException("no");
+ if(!file.isDirectory())
+ throw new BuildException("no");
+ DirectoryScanner ds = getDirectoryScanner(file);
+ String[] files = ds.getIncludedFiles();
+ for(int j = 0; j < files.length ; j++){
+ if(files[j].endsWith(".java"/*nonNLS*/)){
+ arguments.append(" "/*nonNLS*/);
+ arguments.append(new File(file,files[j]).getAbsolutePath());
+ }
+ }
+ }
+
+ try {
+ Main.compile(arguments.toString(),new AntPrintWriter(this));
+ }
+ catch(Exception e){
+ throw new BuildException("Jdtcom"/*nonNLS*/,e);
+ }
+ log("FINISH"/*nonNLS*/);
+ }
+
+ public void setProceedonerror(boolean proceed){
+ if(proceed)
+ arguments.append(" -proceedOnError"/*nonNLS*/);
+ }
+
+ public void setTime(boolean time){
+ if(time)
+ arguments.append(" -time"/*nonNLS*/);
+ }
+
+ public void setVersion(boolean version){
+ if(version)
+ arguments.append(" -version"/*nonNLS*/);
+ }
+
+ public void setNoimporterror(boolean noimporterror){
+ if(noimporterror)
+ arguments.append(" -noImportError"/*nonNLS*/);
+ }
+
+ public void setVerbose(boolean verbose){
+ if(verbose)
+ arguments.append(" -verbose"/*nonNLS*/);
+ }
+
+ public void setReferenceinfo(boolean referenceinfo){
+ if(referenceinfo)
+ arguments.append(" -referenceInfo"/*nonNLS*/);
+ }
+
+ public void setPreservealllocals(boolean preservealllocals){
+ if(preservealllocals)
+ arguments.append(" -preserveAllLocals"/*nonNLS*/);
+ }
+
+ public void setTarget(String target){
+ if (!target.equals("1.1"/*nonNLS*/) && !target.equals("1.2"/*nonNLS*/))
+ throw new BuildException("no");
+ arguments.append(" -target "/*nonNLS*/);
+ arguments.append(target);
+ }
+
+ public void setLog(File log){
+ try {
+ new PrintWriter(new FileOutputStream(log.getAbsolutePath(), false));
+ } catch(IOException e){
+ throw new BuildException("no");
+ }
+ arguments.append(" -log "/*nonNLS*/);
+ arguments.append(log.getAbsolutePath());
+ }
+
+ public void setRepeat(int repeat){
+ if(repeat < 0)
+ throw new BuildException("no");
+ arguments.append(" -repeat "/*nonNLS*/);
+ arguments.append(String.valueOf(repeat));
+ }
+
+ public void setWarning(String warning){
+ if(warning.equals("no"/*nonNLS*/)){
+ arguments.append(" -nowarn"/*nonNLS*/);
+ }
+ else{
+ StringTokenizer tokenizer = new StringTokenizer(warning, ","/*nonNLS*/);
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (!token.equals("constructorName"/*nonNLS*/) &&
+ !token.equals("packageDefaultMethod"/*nonNLS*/) &&
+ !token.equals("maskedCatchBlocks"/*nonNLS*/) &&
+ !token.equals("deprecation"/*nonNLS*/) &&
+ !token.equals("unusedLocals"/*nonNLS*/) &&
+ !token.equals("unusedArguments"/*nonNLS*/) &&
+ !token.equals("syntheticAccess"/*nonNLS*/) &&
+ !token.equals("nls"/*nonNLS*/))
+ throw new BuildException("no");
+ }
+ arguments.append(" -warn:"/*nonNLS*/+warning);
+ }
+ }
+
+ public void setDebug(String debug){
+ if(debug.equals("no"/*nonNLS*/)){
+ arguments.append(" -g:none"/*nonNLS*/);
+ }
+ else if (debug.equals("all"/*nonNLS*/)){
+ arguments.append(" -g"/*nonNLS*/);
+ }
+ else{
+ StringTokenizer tokenizer = new StringTokenizer(debug, ","/*nonNLS*/);
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (!token.equals("vars"/*nonNLS*/) && !token.equals("lines"/*nonNLS*/) && !token.equals("source"/*nonNLS*/))
+ throw new BuildException("no");
+ }
+ arguments.append(" -g:"/*nonNLS*/+debug);
+ }
+ }
+
+ public void setDestdir(File dest){
+ this.dest = dest;
+ }
+
+ public void setClasspath(Path path){
+ if (classpath == null) {
+ classpath = path;
+ }
+ classpath.append(path);
+ }
+
+ public void setSrcdir(Path path){
+ if (src == null) {
+ src = path;
+ }
+ src.append(path);
+ }
+
+ public Path createSrc() {
+ if (src == null) {
+ src = new Path(project);
+ }
+ return src.createPath();
+ }
+}
+
diff --git a/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/AntPrintWriter.java b/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/AntPrintWriter.java new file mode 100644 index 0000000000..b4ba155564 --- /dev/null +++ b/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/AntPrintWriter.java @@ -0,0 +1,136 @@ +package org.eclipse.jdt.internal.core.ant;
+
+import java.io.*;
+
+import org.apache.tools.ant.*;
+
+public class AntPrintWriter extends PrintWriter {
+ private Task task;
+ private String currentLine;
+
+ public AntPrintWriter(Task t){
+ super(System.out);
+ task = t;
+ currentLine = ""/*nonNLS*/;
+ }
+
+ public void flush() {
+ task.log(currentLine);
+ currentLine = ""/*nonNLS*/;
+ }
+
+ public void close() {
+ flush();
+ }
+
+ public void write(int c) {
+ currentLine += String.valueOf(c);
+ }
+
+ public void write(char buf[], int off, int len) {
+ currentLine += new String(buf).substring(off,off+len);
+ }
+
+ public void write(char buf[]) {
+ write(buf, 0, buf.length);
+ }
+
+
+ public void write(String s, int off, int len) {
+ currentLine += s.substring(off,off+len);
+ }
+
+ public void write(String s) {
+ write(s, 0, s.length());
+ }
+
+ public void print(boolean b) {
+ write(b ? "true"/*nonNLS*/ : "false"/*nonNLS*/);
+ }
+
+ public void print(char c) {
+ write(String.valueOf(c));
+ }
+
+ public void print(int i) {
+ write(String.valueOf(i));
+ }
+
+ public void print(long l) {
+ write(String.valueOf(l));
+ }
+
+ public void print(float f) {
+ write(String.valueOf(f));
+ }
+
+ public void print(double d) {
+ write(String.valueOf(d));
+ }
+
+ public void print(char s[]) {
+ write(s);
+ }
+
+
+ public void print(String s) {
+ if (s == null) {
+ s = "null"/*nonNLS*/;
+ }
+ write(s);
+ }
+
+ public void print(Object obj) {
+ write(String.valueOf(obj));
+ }
+
+ public void println() {
+ flush();
+ }
+
+ public void println(boolean x) {
+ print(x);
+ println();
+ }
+
+ public void println(char x) {
+ print(x);
+ println();
+ }
+
+ public void println(int x) {
+ print(x);
+ println();
+ }
+
+ public void println(long x) {
+ print(x);
+ println();
+ }
+
+ public void println(float x) {
+ print(x);
+ println();
+ }
+
+ public void println(double x) {
+ print(x);
+ println();
+ }
+
+ public void println(char x[]) {
+ print(x);
+ println();
+ }
+
+ public void println(String x) {
+ print(x);
+ println();
+ }
+
+ public void println(Object x) {
+ print(x);
+ println();
+ }
+}
+
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java index d6d2a47183..0105201202 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java @@ -69,6 +69,9 @@ public class Main implements ConfigurableProblems, ProblemSeverities { JDK1_1 = ((ver != null) && ver.startsWith("1.1"/*nonNLS*/));
relocalize();
}
+
+ private boolean proceed = true;
+
protected Main(PrintWriter writer, boolean systemExitWhenFinished) {
this.out = writer;
this.systemExitWhenFinished = systemExitWhenFinished;
@@ -81,64 +84,66 @@ protected void compile(String[] argv) { // decode command line arguments
try {
configure(argv);
- if (showProgress) System.out.print(Main.bind("progress.compiling"/*nonNLS*/));
- for (int i = 0; i < repetitions; i++){
- globalProblemsCount = 0;
- globalErrorsCount = 0;
- globalWarningsCount = 0;
- lineCount = 0;
- if (repetitions > 1){
- out.flush();
- out.println(Main.bind("compile.repetition"/*nonNLS*/,String.valueOf(i+1),String.valueOf(repetitions)));
- }
- long startTime = System.currentTimeMillis();
-
- // request compilation
- performCompilation();
- if (timer) {
- time = System.currentTimeMillis() - startTime;
- if (lineCount != 0){
- out.println(Main.bind("compile.instantTime"/*nonNLS*/,new String[]{String.valueOf(lineCount),String.valueOf(time),String.valueOf((((int)((lineCount*10000.0)/time))/10.0))}));
- } else {
- out.println(Main.bind("compile.totalTime"/*nonNLS*/,String.valueOf(time)));
-
- }
- }
- if (globalProblemsCount > 0) {
- if (globalProblemsCount == 1) {
- out.print(Main.bind("compile.oneProblem"/*nonNLS*/));
- } else {
- out.print(Main.bind("compile.severalProblems"/*nonNLS*/,String.valueOf(globalProblemsCount)));
+ if(proceed){
+ if (showProgress) out.print(Main.bind("progress.compiling"/*nonNLS*/));
+ for (int i = 0; i < repetitions; i++){
+ globalProblemsCount = 0;
+ globalErrorsCount = 0;
+ globalWarningsCount = 0;
+ lineCount = 0;
+
+ if (repetitions > 1){
+ out.flush();
+ out.println(Main.bind("compile.repetition"/*nonNLS*/,String.valueOf(i+1),String.valueOf(repetitions)));
}
- out.print(" ("/*nonNLS*/);
- if (globalErrorsCount > 0) {
- if (globalErrorsCount == 1) {
- out.print(Main.bind("compile.oneError"/*nonNLS*/));
+ long startTime = System.currentTimeMillis();
+ // request compilation
+ performCompilation();
+ if (timer) {
+
+ time = System.currentTimeMillis() - startTime;
+ if (lineCount != 0){
+ out.println(Main.bind("compile.instantTime"/*nonNLS*/,new String[]{String.valueOf(lineCount),String.valueOf(time),String.valueOf((((int)((lineCount*10000.0)/time))/10.0))}));
} else {
- out.print(Main.bind("compile.severalErrors"/*nonNLS*/,String.valueOf(globalErrorsCount)));
+ out.println(Main.bind("compile.totalTime"/*nonNLS*/,String.valueOf(time)));
}
}
- if (globalWarningsCount > 0) {
+ if (globalProblemsCount > 0) {
+ if (globalProblemsCount == 1) {
+ out.print(Main.bind("compile.oneProblem"/*nonNLS*/));
+ } else {
+ out.print(Main.bind("compile.severalProblems"/*nonNLS*/,String.valueOf(globalProblemsCount)));
+ }
+ out.print(" ("/*nonNLS*/);
if (globalErrorsCount > 0) {
- out.print(", "/*nonNLS*/);
+ if (globalErrorsCount == 1) {
+ out.print(Main.bind("compile.oneError"/*nonNLS*/));
+ } else {
+ out.print(Main.bind("compile.severalErrors"/*nonNLS*/,String.valueOf(globalErrorsCount)));
+ }
}
- if (globalWarningsCount == 1) {
- out.print(Main.bind("compile.oneWarning"/*nonNLS*/));
- } else {
- out.print(Main.bind("compile.severalWarnings"/*nonNLS*/,String.valueOf(globalWarningsCount)));
+ if (globalWarningsCount > 0) {
+ if (globalErrorsCount > 0) {
+ out.print(", "/*nonNLS*/);
+ }
+ if (globalWarningsCount == 1) {
+ out.print(Main.bind("compile.oneWarning"/*nonNLS*/));
+ } else {
+ out.print(Main.bind("compile.severalWarnings"/*nonNLS*/,String.valueOf(globalWarningsCount)));
+ }
}
+ out.println(")"/*nonNLS*/);
}
- out.println(")"/*nonNLS*/);
- }
- if (exportedClassFilesCounter != 0 && (this.showProgress || this.timer || this.verbose)) {
- if (exportedClassFilesCounter == 1) {
- out.print(Main.bind("compile.oneClassFileGenerated"/*nonNLS*/));
- } else {
- out.print(Main.bind("compile.severalClassFilesGenerated"/*nonNLS*/,String.valueOf(exportedClassFilesCounter)));
+ if (exportedClassFilesCounter != 0 && (this.showProgress || this.timer || this.verbose)) {
+ if (exportedClassFilesCounter == 1) {
+ out.print(Main.bind("compile.oneClassFileGenerated"/*nonNLS*/));
+ } else {
+ out.print(Main.bind("compile.severalClassFilesGenerated"/*nonNLS*/,String.valueOf(exportedClassFilesCounter)));
+ }
}
}
+ if (showProgress) System.out.println();
}
- if (showProgress) System.out.println();
if (systemExitWhenFinished){
out.flush();
System.exit(globalErrorsCount > 0 ? -1 : 0);
@@ -507,11 +512,13 @@ private void configure(String[] argv) throws InvalidInputException { if (versionIDRequired) {
out.println(Main.bind("configure.version"/*nonNLS*/,this.versionID));
out.println();
+ proceed = false;
return;
}
if (printUsageRequired) {
printUsage();
+ proceed = false;
return;
}
@@ -556,6 +563,7 @@ private void configure(String[] argv) throws InvalidInputException { } else {
showProgress = false;
}
+
if (repetitions == 0) {
repetitions = 1;
}
@@ -620,7 +628,6 @@ protected ICompilerRequestor getBatchRequestor() { protected CompilationUnit[] getCompilationUnits() throws InvalidInputException {
int fileCount = filenames.length;
CompilationUnit[] units = new CompilationUnit[fileCount];
-
HashtableOfObject knownFileNames = new HashtableOfObject(fileCount);
for (int i = 0; i < fileCount; i++) {
@@ -722,12 +729,10 @@ protected void performCompilation() throws InvalidInputException { getOptions(),
getBatchRequestor(),
getProblemFactory());
-
CompilerOptions options = batchCompiler.options;
// set the non-externally configurable options.
options.setVerboseMode(verbose);
options.produceReferenceInfo(produceRefInfo);
-
batchCompiler.compile(getCompilationUnits());
}
private void printUsage() {
|