aboutsummaryrefslogtreecommitdiffstats
path: root/taskdefs/src
diff options
context:
space:
mode:
authorwisberg <wisberg>2005-03-22 21:02:34 +0000
committerwisberg <wisberg>2005-03-22 21:02:34 +0000
commit1dbed37c0e72fce1f4c4c01ada2c980b6e6a8541 (patch)
treeb1962199818074ee35ecce25a5ad8a0ecdda8d2c /taskdefs/src
parentb5f4d09e4f4e45943c6c8b3dc8dca0c05b90f27c (diff)
downloadaspectj-1dbed37c0e72fce1f4c4c01ada2c980b6e6a8541.tar.gz
aspectj-1dbed37c0e72fce1f4c4c01ada2c980b6e6a8541.zip
bug 53209 - inpathDirCopyFilter
Diffstat (limited to 'taskdefs/src')
-rw-r--r--taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java92
1 files changed, 84 insertions, 8 deletions
diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
index 7f117d87e..ffa97d124 100644
--- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
+++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
@@ -327,7 +327,10 @@ public class AjcTask extends MatchingTask {
/** non-null if copying all source root files but the filtered ones */
private String sourceRootCopyFilter;
-
+
+ /** non-null if copying all inpath dir files but the filtered ones */
+ private String inpathDirCopyFilter;
+
/** directory sink for classes */
private File destDir;
@@ -394,6 +397,7 @@ public class AjcTask extends MatchingTask {
messageHolder = null;
outjar = null;
sourceRootCopyFilter = null;
+ inpathDirCopyFilter = null;
sourceRoots = null;
srcdir = null;
tmpOutjar = null;
@@ -680,6 +684,28 @@ public class AjcTask extends MatchingTask {
public void setSourceRootCopyFilter(String filter){
this.sourceRootCopyFilter = filter;
}
+ /**
+ * Option to copy all files from
+ * all inpath directories
+ * except the files specified here.
+ * If this is specified and inpath directories are specified,
+ * then this will copy all files except
+ * those specified in the filter pattern.
+ * Requires inpath.
+ * If the input does not contain "**\/*.class", then
+ * this prepends it, to avoid overwriting woven classes
+ * with unwoven input.
+ * @param filter a String acceptable as an excludes
+ * filter for an Ant Zip fileset.
+ */
+ public void setInpathDirCopyFilter(String filter){
+ if (null != filter) {
+ if (-1 == filter.indexOf("**/*.class")) {
+ filter = "**/*.class," + filter;
+ }
+ }
+ this.inpathDirCopyFilter = filter;
+ }
public void setX(String input) { // ajc-only eajc-also docDone
StringTokenizer tokens = new StringTokenizer(input, ",", false);
@@ -1004,7 +1030,8 @@ public class AjcTask extends MatchingTask {
// when copying resources, use temp jar for class output
// then copy temp jar contents and resources to output jar
if ((null != outjar) && !outjarFixedup) {
- if (copyInjars || copyInpath || (null != sourceRootCopyFilter)) {
+ if (copyInjars || copyInpath || (null != sourceRootCopyFilter)
+ || (null != inpathDirCopyFilter)) {
String path = outjar.getAbsolutePath();
int len = FileUtil.zipSuffixLength(path);
if (len < 1) {
@@ -1103,10 +1130,16 @@ public class AjcTask extends MatchingTask {
if (fork && isInIncrementalMode() && !isInIncrementalFileMode()) {
sb.append("can fork incremental only using tag file.\n");
}
- if ((null != sourceRootCopyFilter) && (null == outjar)
- && (DEFAULT_DESTDIR == destDir)) {
- final String REQ = " requires dest dir or output jar.\n"; sb.append("sourceRootCopyFilter");
- sb.append(REQ);
+ if (((null != inpathDirCopyFilter) || (null != sourceRootCopyFilter))
+ && (null == outjar) && (DEFAULT_DESTDIR == destDir)) {
+ final String REQ = " requires dest dir or output jar.\n";
+ if (null == inpathDirCopyFilter) {
+ sb.append("sourceRootCopyFilter");
+ } else if (null == sourceRootCopyFilter) {
+ sb.append("inpathDirCopyFilter");
+ } else {
+ sb.append("sourceRootCopyFilter and inpathDirCopyFilter");
+ } sb.append(REQ);
}
if (0 < sb.length()) {
throw new BuildException(sb.toString());
@@ -1475,7 +1508,8 @@ public class AjcTask extends MatchingTask {
* (if XCopyInjars is enabled).
*/
private void completeDestdir() {
- if (!copyInjars && (null == sourceRootCopyFilter)) {
+ if (!copyInjars && (null == sourceRootCopyFilter)
+ && (null == inpathDirCopyFilter)) {
return;
} else if ((destDir == DEFAULT_DESTDIR)
|| !destDir.canWrite()) {
@@ -1521,6 +1555,31 @@ public class AjcTask extends MatchingTask {
copy.execute();
}
}
+ if ((null != inpathDirCopyFilter) && (null != inpath)) {
+ String[] paths = inpath.list();
+ if (!LangUtil.isEmpty(paths)) {
+ Copy copy = new Copy();
+ copy.setProject(project);
+ copy.setTodir(destDir);
+ boolean gotDir = false;
+ for (int i = 0; i < paths.length; i++) {
+ File inpathDir = new File(paths[i]);
+ if (inpathDir.isDirectory() && inpathDir.canRead()) {
+ if (!gotDir) {
+ gotDir = true;
+ }
+ FileSet fileSet = new FileSet();
+ fileSet.setDir(inpathDir);
+ fileSet.setIncludes("**/*");
+ fileSet.setExcludes(inpathDirCopyFilter);
+ copy.addFileset(fileSet);
+ }
+ }
+ if (gotDir) {
+ copy.execute();
+ }
+ }
+ }
}
/**
@@ -1531,7 +1590,8 @@ public class AjcTask extends MatchingTask {
*/
private void completeOutjar() {
if (((null == tmpOutjar) || !tmpOutjar.canRead())
- || (!copyInjars && (null == sourceRootCopyFilter))) {
+ || (!copyInjars && (null == sourceRootCopyFilter)
+ && (null == inpathDirCopyFilter))) {
return;
}
Zip zip = new Zip();
@@ -1572,6 +1632,22 @@ public class AjcTask extends MatchingTask {
}
}
}
+ if ((null != inpathDirCopyFilter) && (null != inpath)) {
+ String[] paths = inpath.list();
+ if (!LangUtil.isEmpty(paths)) {
+ for (int i = 0; i < paths.length; i++) {
+ File inpathDir = new File(paths[i]);
+ if (inpathDir.isDirectory() && inpathDir.canRead()) {
+ FileSet fileset = new FileSet();
+ fileset.setProject(project);
+ fileset.setDir(inpathDir);
+ fileset.setIncludes("**/*");
+ fileset.setExcludes(inpathDirCopyFilter);
+ zip.addFileset(fileset);
+ }
+ }
+ }
+ }
zip.execute();
}