From d850ca48e8696e82b319c5b17377d6f19df2b719 Mon Sep 17 00:00:00 2001 From: wisberg Date: Wed, 23 Apr 2003 08:33:39 +0000 Subject: [PATCH] extracted classpath setup method for testing --- .../tools/ant/taskdefs/AntBuilder.java | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index 233adce1e..80051fd7c 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -241,6 +241,32 @@ public class AntBuilder extends Builder { // -- classpath Path classpath = new Path(project); + boolean hasLibraries = setupClasspath(module, classpath); + // need to add system classes?? + boolean inEclipse = true; // XXX detect, fork only in eclipse + if (hasLibraries && inEclipse) { + javac.setFork(true); // XXX otherwise never releases library jars + } + + // -- set output directory + classpath.createPathElement().setLocation(classesDir); + javac.setClasspath(classpath); + // misc + javac.setDebug(true); + // compile + try { + return executeTask(javac); + } catch (BuildException e) { + String args = "" + Arrays.asList(javac.getCurrentCompilerArgs()); + errors.add("BuildException compiling " + module.toLongString() + args + + ": " + Util.renderException(e)); + return false; + } finally { + javac.init(); // be nice to let go of classpath libraries... + } + } + + public boolean setupClasspath(Module module, Path classpath) { // XXX fix test access boolean hasLibraries = false; // required libraries for (Iterator iter = module.getLibJars().iterator(); iter.hasNext();) { @@ -265,28 +291,7 @@ public class AntBuilder extends Builder { classpath.createPathElement().setLocation((File) iterator.next()); } } - // need to add system classes?? - boolean inEclipse = true; // XXX detect, fork only in eclipse - if (hasLibraries && inEclipse) { - javac.setFork(true); // XXX otherwise never releases library jars - } - - // -- set output directory - classpath.createPathElement().setLocation(classesDir); - javac.setClasspath(classpath); - // misc - javac.setDebug(true); - // compile - try { - return executeTask(javac); - } catch (BuildException e) { - String args = "" + Arrays.asList(javac.getCurrentCompilerArgs()); - errors.add("BuildException compiling " + module.toLongString() + args - + ": " + Util.renderException(e)); - return false; - } finally { - javac.init(); // be nice to let go of classpath libraries... - } + return hasLibraries; } /** -- 2.39.5