summaryrefslogtreecommitdiffstats
path: root/build/src
diff options
context:
space:
mode:
authorwisberg <wisberg>2005-03-08 07:33:33 +0000
committerwisberg <wisberg>2005-03-08 07:33:33 +0000
commitd52953ffcad47ffc3f2825dc6c70a79f5e92fea2 (patch)
treed785d5c8fe40f6f9f1115fbfb0bac0c6f81aefde /build/src
parent184a094db7264fb8e1f2be31fedf71d0d76834bc (diff)
downloadaspectj-d52953ffcad47ffc3f2825dc6c70a79f5e92fea2.tar.gz
aspectj-d52953ffcad47ffc3f2825dc6c70a79f5e92fea2.zip
skipped libraries and resource patterns moved into .properties file; better error reporting
Diffstat (limited to 'build/src')
-rw-r--r--build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java10
-rw-r--r--build/src/org/aspectj/internal/tools/build/Builder.java80
2 files changed, 80 insertions, 10 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 cec68badb..31ea9e833 100644
--- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
+++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
@@ -302,6 +302,10 @@ public class AntBuilder extends Builder {
passed = executeTask(AspectJSupport.wrapIfNeeded(module, javac));
} catch (BuildException e) {
failure = e;
+ } catch (Error e) {
+ failure = new BuildException(e);
+ } catch (RuntimeException e) {
+ failure = new BuildException(e);
} finally {
javac.init(); // be nice to let go of classpath libraries...
}
@@ -368,6 +372,7 @@ public class AntBuilder extends Builder {
// -- merge any merge jars
List mergeJars = module.getMerges();
+ removeLibraryFilesToSkip(module, mergeJars);
// final boolean useManifest = false;
if (0 < mergeJars.size()) {
for (Iterator iter = mergeJars.iterator(); iter.hasNext();) {
@@ -469,8 +474,8 @@ public class AntBuilder extends Builder {
zip.setDestFile(module.getAssembledJar());
ZipFileSet zipfileset = null;
- ArrayList known = module.findKnownJarAntecedants();
-
+ List known = module.findKnownJarAntecedants();
+ removeLibraryFilesToSkip(module, known);
// -- merge any antecedents, less any manifest
for (Iterator iter = known.iterator(); iter.hasNext();) {
File jarFile = (File) iter.next();
@@ -601,7 +606,6 @@ public class AntBuilder extends Builder {
* under srcDir.
* Written reflectively to compile in the build module,
* which can't depend on the whole tree.
- * TODO output from ajc is hidden on failure.
* @param javac the Javac specification
* @param toolsJar the Path to the aspectjtools.jar
* @param runtimeJar the Path to the aspectjrt.jar
diff --git a/build/src/org/aspectj/internal/tools/build/Builder.java b/build/src/org/aspectj/internal/tools/build/Builder.java
index 88dcd7553..dbb0c40fe 100644
--- a/build/src/org/aspectj/internal/tools/build/Builder.java
+++ b/build/src/org/aspectj/internal/tools/build/Builder.java
@@ -18,10 +18,12 @@ import java.io.FileFilter;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Properties;
+import java.util.StringTokenizer;
import org.apache.tools.ant.BuildException;
@@ -87,13 +89,11 @@ public abstract class Builder {
* properties to tunnel for filters. hmm.
*/
- public static final String RESOURCE_PATTERN =
- "**/*.txt,**/*.rsc,**/*.gif,**/*.properties";
+ public static final String RESOURCE_PATTERN;
- public static final String BINARY_SOURCE_PATTERN =
- "**/*.rsc,**/*.gif,**/*.jar,**/*.zip";
+ public static final String BINARY_SOURCE_PATTERN;
- public static final String ALL_PATTERN = "**/*";
+ public static final String ALL_PATTERN;
/** enable copy filter semantics */
protected static final boolean FILTER_ON = true;
@@ -101,18 +101,60 @@ public abstract class Builder {
/** disable copy filter semantics */
protected static final boolean FILTER_OFF = false;
+ /** define libraries to skip as comma-delimited values for this key */
+ private static final String SKIP_LIBRARIES_KEY = "skip.libraries";
+
+ /** List (String) names of libraries to skip during assembly */
+ private static final List SKIP_LIBRARIES;
private static final String ERROR_KEY = "error loading properties";
private static final Properties PROPS;
static {
PROPS = new Properties();
+ List skips = Collections.EMPTY_LIST;
+ String resourcePattern = "**/*.txt,**/*.rsc,**/*.gif,**/*.properties";
+ String allPattern = "**/*";
+ String binarySourcePattern = "**/*.rsc,**/*.gif,**/*.jar,**/*.zip";
String name = Builder.class.getName().replace('.', '/') + ".properties";
try {
InputStream in = Builder.class.getClassLoader().getResourceAsStream(name);
- PROPS.load(in);
+ PROPS.load(in);
+ allPattern = PROPS.getProperty("all.pattern");
+ resourcePattern = PROPS.getProperty("resource.pattern");
+ binarySourcePattern = PROPS.getProperty("binarySource.pattern");
+ skips = commaStrings(PROPS.getProperty(SKIP_LIBRARIES_KEY));
} catch (Throwable t) {
- String m = "unable to load " + name + ": " + t.getClass() + " " + t;
+ if (t instanceof ThreadDeath) {
+ throw (ThreadDeath) t;
+ }
+ String m = "error loading " + name + ": " + t.getClass() + " " + t;
PROPS.setProperty(ERROR_KEY, m);
}
+ SKIP_LIBRARIES = skips;
+ ALL_PATTERN = allPattern;
+ BINARY_SOURCE_PATTERN = binarySourcePattern;
+ RESOURCE_PATTERN = resourcePattern;
+ }
+
+ /**
+ * Splits strings into an unmodifable <code>List</code> of String
+ * using comma as the delimiter and trimming whitespace from the result.
+ *
+ * @param text <code>String</code> to split.
+ * @return unmodifiable List (String) of String delimited by comma in text
+ */
+ public static List commaStrings(String text) {
+ if ((null == text) || (0 == text.length())) {
+ return Collections.EMPTY_LIST;
+ }
+ List strings = new ArrayList();
+ StringTokenizer tok = new StringTokenizer(text, ",");
+ while (tok.hasMoreTokens()) {
+ String token = tok.nextToken().trim();
+ if (0 < token.length()) {
+ strings.add(token);
+ }
+ }
+ return Collections.unmodifiableList(strings);
}
/**
* Map delivered-jar name to created-module name
@@ -516,6 +558,28 @@ public abstract class Builder {
return (ProductModule[]) results.toArray(new ProductModule[0]);
}
+ /**
+ * Subclasses should query whether to include library files in the assembly.
+ * @param module the Module being built
+ * @param libraries the List of File path to the jar to consider assembling
+ * @return true if the jar should be included, false otherwise.
+ */
+ protected void removeLibraryFilesToSkip(Module module, List libraries) {
+ for (ListIterator liter = libraries.listIterator(); liter.hasNext();) {
+ File library= (File) liter.next();
+ final String fname = library.getName();
+ if (null != fname) {
+ for (Iterator iter = SKIP_LIBRARIES.iterator(); iter.hasNext();) {
+ String name = (String) iter.next();
+ if (fname.equals(name)) {
+ liter.remove();
+ break;
+ }
+ }
+ }
+ }
+ }
+
/**
* @return String[] names of modules to build for this module
*/
@@ -539,6 +603,7 @@ public abstract class Builder {
/**
* Assemble the module distribution from the classesDir, saving String errors.
+ * @see #removeLibraryFilesToSkip(Module, File)
*/
abstract protected boolean assemble(
Module module,
@@ -548,6 +613,7 @@ public abstract class Builder {
/**
* Assemble the module distribution from the classesDir and all antecendants,
* saving String errors.
+ * @see #removeLibraryFilesToSkip(Module, File)
*/
abstract protected boolean assembleAll(
Module module,