summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormwebster <mwebster>2006-06-02 12:47:08 +0000
committermwebster <mwebster>2006-06-02 12:47:08 +0000
commit319a0d15703c098b74335ecb9672f58166bf3c5b (patch)
tree79e1c99955a8c5de1001269352369723eba48082
parent30ba1f01085bb48d8fb599ebf072dbc0b547cdfb (diff)
downloadaspectj-319a0d15703c098b74335ecb9672f58166bf3c5b.tar.gz
aspectj-319a0d15703c098b74335ecb9672f58166bf3c5b.zip
132591 - Duplicate exception with aop.xml file on aspectpath
-rw-r--r--ajde/testdata/OutxmlTest/outxml-to-outjar-with-aop_xml.lst1
-rw-r--r--ajde/testdata/OutxmlTest/src-resources/META-INF/aop.xml2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java33
-rw-r--r--ajde/testsrc/org/aspectj/ajde/OutxmlTest.java27
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java11
5 files changed, 64 insertions, 10 deletions
diff --git a/ajde/testdata/OutxmlTest/outxml-to-outjar-with-aop_xml.lst b/ajde/testdata/OutxmlTest/outxml-to-outjar-with-aop_xml.lst
new file mode 100644
index 000000000..87c980224
--- /dev/null
+++ b/ajde/testdata/OutxmlTest/outxml-to-outjar-with-aop_xml.lst
@@ -0,0 +1 @@
+-outxml
diff --git a/ajde/testdata/OutxmlTest/src-resources/META-INF/aop.xml b/ajde/testdata/OutxmlTest/src-resources/META-INF/aop.xml
new file mode 100644
index 000000000..77505c753
--- /dev/null
+++ b/ajde/testdata/OutxmlTest/src-resources/META-INF/aop.xml
@@ -0,0 +1,2 @@
+<aspectj>
+</aspectj> \ No newline at end of file
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
index dd06f9eca..5a38d443d 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
@@ -120,19 +120,32 @@ public class NullIdeProperties implements ProjectPropertiesAdapter {
}
public Map getSourcePathResources() {
- File srcBase = new File(getProjectSourcePath());
- File[] fromResources = FileUtil.listFiles(srcBase, new FileFilter() {
- public boolean accept(File pathname) {
- String name = pathname.getName().toLowerCase();
- return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj");
- }
- });
Map map = new HashMap();
- for (int i = 0; i < fromResources.length; i++) {
- String normPath = FileUtil.normalizedPath(fromResources[i] ,srcBase);
- map.put(normPath, fromResources[i]);
+ /* Allow the user to override the testProjectPath by using sourceRoots */
+ File[] srcBase;
+ if (sourceRoots == null || sourceRoots.isEmpty()) {
+ srcBase = new File[] { new File(getProjectSourcePath()) };
+ }
+ else {
+ srcBase = new File[sourceRoots.size()];
+ sourceRoots.toArray(srcBase);
+ }
+
+ for (int j = 0; j < srcBase.length; j++) {
+ File[] fromResources = FileUtil.listFiles(srcBase[j], new FileFilter() {
+ public boolean accept(File pathname) {
+ String name = pathname.getName().toLowerCase();
+ return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj");
+ }
+ });
+ for (int i = 0; i < fromResources.length; i++) {
+ String normPath = FileUtil.normalizedPath(fromResources[i] ,srcBase[j]);
+ map.put(normPath, fromResources[i]);
+
+ }
}
+
return map;
}
diff --git a/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java b/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java
index ca01e4c78..b4fff912b 100644
--- a/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java
@@ -13,6 +13,9 @@ package org.aspectj.ajde;
import java.io.File;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -103,6 +106,30 @@ public class OutxmlTest extends AjdeTestCase {
assertJarContainsEntry(outjar,CUSTOM_AOPXML_NAME);
}
+ /**
+ * Aim: Test "-outxml" option produces a warning if "META-INF/aop.xml
+ * already exists in source
+ *
+ */
+ public void testOutxmlToOutjarWithAop_xml () {
+ File f = new File( AjdeTests.testDataPath(PROJECT_DIR + "/src-resources"));
+ Set roots = new HashSet();
+ roots.add(f);
+ ideManager.getProjectProperties().setSourceRoots(roots);
+ File outjar = openFile(OUTJAR_NAME);
+ ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
+ assertTrue("Build failed: " + ideManager.getCompilationSourceLineTasks(),doSynchronousBuild("outxml-to-outjar-with-aop_xml.lst"));
+// assertTrue("Build warnings: " + ideManager.getCompilationSourceLineTasks(),ideManager.getCompilationSourceLineTasks().isEmpty());
+ assertFalse("Build warnings for exisiting resource expected",ideManager.getCompilationSourceLineTasks().isEmpty());
+ List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
+ String msg = ((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage();
+ assertTrue("Wrong message: " + msg,msg.startsWith("-outxml/-outxmlfile option ignored because resource already exists:"));
+
+ File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
+ assertFalse(DEFAULT_AOPXML_NAME + " should not exisit",aopxml.exists());
+ assertJarContainsEntry(outjar,DEFAULT_AOPXML_NAME);
+ }
+
private void assertJarContainsEntry (File file, String entryName) {
try {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index eb02ba5c7..d2b09def2 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -132,6 +132,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
// FIXME asc should this really be in here?
private IHierarchy structureModel;
public AjBuildConfig buildConfig;
+ private boolean ignoreOutxml;
AjState state = new AjState(this);
@@ -495,6 +496,14 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
handler.handleMessage(msg);
return;
}
+ if (filename.equals(buildConfig.getOutxmlName())) {
+ ignoreOutxml = true;
+ IMessage msg = new Message("-outxml/-outxmlfile option ignored because resource already exists: '" + filename + "'",
+ IMessage.WARNING,
+ null,
+ new SourceLocation(srcLocation,0));
+ handler.handleMessage(msg);
+ }
if (zos != null) {
ZipEntry newEntry = new ZipEntry(filename); //??? get compression scheme right
@@ -555,6 +564,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
}
private void writeOutxmlFile () throws IOException {
+ if (ignoreOutxml) return;
+
String filename = buildConfig.getOutxmlName();
// System.err.println("? AjBuildManager.writeOutxmlFile() outxml=" + filename);
// System.err.println("? AjBuildManager.writeOutxmlFile() outputDir=" + buildConfig.getOutputDir());