]> source.dussan.org Git - aspectj.git/commitdiff
124460: aop.xml used for compilation: AJDT interface support
authoraclement <aclement>
Thu, 12 Feb 2009 16:40:08 +0000 (16:40 +0000)
committeraclement <aclement>
Thu, 12 Feb 2009 16:40:08 +0000 (16:40 +0000)
tests/src/org/aspectj/systemtest/ajc164/ajc164.xml
tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

index 7b984bc581b70a9cf0535b398fc2841764a9135c..ee331cc03bc8f97b3bf0ab260901ba709356392f 100644 (file)
@@ -3,7 +3,7 @@
 <suite>
     
     <ajc-test dir="features164/aopconfig/one" title="aop config - 1">
-      <compile files="A.java A2.java B.java foo.xml" options="-1.5 -showWeaveInfo">
+      <compile files="A.java A2.java B.java foo.xml" options="-1.5 -showWeaveInfo -xmlConfigured">
         <message kind="weave" text="Join point 'staticinitialization(void A.&lt;clinit&gt;())' in Type 'A' (A.java:1) advised by before advice from 'A' (A.java:2)"/>
         <message kind="weave" text="Join point 'staticinitialization(void A2.&lt;clinit&gt;())' in Type 'A2' (A2.java:1) advised by before advice from 'A' (A.java:2)"/>
         <message kind="weave" text="Join point 'staticinitialization(void B.&lt;clinit&gt;())' in Type 'B' (B.java:1) advised by before advice from 'A' (A.java:2)"/>
     </ajc-test>
     
     <ajc-test dir="features164/aopconfig/one" title="aop config - 2">
-      <compile files="A.java A2.java B.java B2.java foo2.xml" options="-1.5 -showWeaveInfo">
+      <compile files="A.java A2.java B.java B2.java foo2.xml" options="-1.5 -showWeaveInfo -xmlConfigured">
         <message kind="weave" text="Join point 'staticinitialization(void B.&lt;clinit&gt;())' in Type 'B' (B.java:1) advised by before advice from 'A' (A.java:2)"/>
       </compile>
     </ajc-test>
     
     <ajc-test dir="features164/aopconfig/two" title="aop config - 3">
       <!-- type pattern in the scope in foo.xml is complete nonsense -->
-      <compile files="A.java B.java foo.xml" options="-1.5 -Xlint:ignore">
+      <compile files="A.java B.java foo.xml" options="-1.5 -Xlint:ignore -xmlConfigured">
        <message kind="error" text="Unable to parse scope as type pattern"/>
       </compile>
     </ajc-test>
index f4e4bdc30639f1f98db93c4b8ba6f0103aa67db6..b528c36c3851e763a795e34a4ee58e07ec7dec39 100644 (file)
@@ -71,6 +71,13 @@ public class AjdeInteractionTestbed extends TestCase {
                ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addProjectSourceFileChanged(changedFile);
        }
 
+       public void addXmlConfigFile(String projectName, String xmlfile) {
+               List l = new ArrayList();
+               l.add(xmlfile);
+               AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+               ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProjectXmlConfigFiles(l);
+       }
+
        public void addClasspathEntry(String projectName, File classpathEntry) {
                AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
                MultiProjTestCompilerConfiguration config = ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration());
@@ -164,6 +171,7 @@ public class AjdeInteractionTestbed extends TestCase {
                AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
                resetCompilerRecords(compiler);
                addSourceFilesToBuild(projectName, compiler);
+               // addXmlConfigFilesToBuild(projectName, compiler);
                pause(1000); // delay to allow previous runs build stamps to be OK
                lognoln("Building project '" + projectName + "'");
                compiler.build();
@@ -184,6 +192,7 @@ public class AjdeInteractionTestbed extends TestCase {
                AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
                resetCompilerRecords(compiler);
                addSourceFilesToBuild(projectName, compiler);
+               addXmlConfigFilesToBuild(projectName, compiler);
                pause(1000); // delay to allow previous runs build stamps to be OK
                lognoln("Building project '" + projectName + "'");
                compiler.buildFresh();
@@ -226,6 +235,26 @@ public class AjdeInteractionTestbed extends TestCase {
                }
        }
 
+       private void addXmlConfigFilesToBuild(String pname, AjCompiler compiler) {
+               File projectBase = new File(sandboxDir, pname);
+               ICompilerConfiguration icc = compiler.getCompilerConfiguration();
+               List currentXmlFiles = icc.getProjectXmlConfigFiles();
+               List collector = new ArrayList();
+               collectUpXmlFiles(projectBase, projectBase, collector);
+               boolean changed = false;
+               for (int i = 0; i < collector.size(); i++) {
+                       if (!currentXmlFiles.contains(collector.get(i)))
+                               changed = true;
+               }
+               for (int i = 0; i < currentXmlFiles.size(); i++) {
+                       if (!collector.contains(currentXmlFiles.get(i)))
+                               changed = true;
+               }
+               if (changed) {
+                       ((MultiProjTestCompilerConfiguration) icc).setProjectXmlConfigFiles(collector);
+               }
+       }
+
        private void collectUpFiles(File location, File base, List collectionPoint) {
                String contents[] = location.list();
                if (contents == null)
@@ -250,6 +279,27 @@ public class AjdeInteractionTestbed extends TestCase {
                }
        }
 
+       private void collectUpXmlFiles(File location, File base, List collectionPoint) {
+               String contents[] = location.list();
+               if (contents == null)
+                       return;
+               for (int i = 0; i < contents.length; i++) {
+                       String string = contents[i];
+                       File f = new File(location, string);
+                       if (f.isDirectory()) {
+                               collectUpXmlFiles(f, base, collectionPoint);
+                       } else if (f.isFile() && f.getName().endsWith(".xml")) {
+                               String fileFound;
+                               try {
+                                       fileFound = f.getCanonicalPath();
+                                       collectionPoint.add(fileFound);
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               }
+       }
+
        /**
         * Make sure no errors have been recorded
         */
index 192900ae613325ef1f3dad9976a9146ae5386755..cfef1fefe6f97a983ae46cba7998ba141f846277 100644 (file)
@@ -41,6 +41,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio
        private List modifiedFiles;
        private List modifiedDirs;
        private List projectSourceFiles = new ArrayList();
+       private List xmlConfigFiles = new ArrayList();
        private String projectPath;
 
        int changed;
@@ -121,6 +122,10 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio
                return projectSourceFiles;
        }
 
+       public List getProjectXmlConfigFiles() {
+               return xmlConfigFiles;
+       }
+
        public List getProjectSourceFilesChanged() {
                log("ICompilerConfiguration.getProjectSourceFilesChanged()");
                return modifiedFiles;
@@ -174,6 +179,11 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio
                this.changed |= ICompilerConfiguration.PROJECTSOURCEFILES_CHANGED;
        }
 
+       public void setProjectXmlConfigFiles(List xmlConfigFiles) {
+               this.xmlConfigFiles = xmlConfigFiles;
+               this.changed |= ICompilerConfiguration.XMLCONFIG_CHANGED;
+       }
+
        public void addProjectSourceFileChanged(File f) {
                if (this.modifiedFiles == null) {
                        this.modifiedFiles = new ArrayList();
index f6fe8428d93b6020bd45cd7152270827c5b2df06..4282ae5afe221ceee2d2c93adaf62c418c1d5306 100644 (file)
@@ -50,6 +50,26 @@ import org.aspectj.util.FileUtil;
  */
 public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed {
 
+       public void testXmlConfiguredProject() {
+               AjdeInteractionTestbed.VERBOSE = true;
+               String p = "xmlone";
+               initialiseProject(p);
+               configureNonStandardCompileOptions(p, "-showWeaveInfo -xmlConfigured");
+               configureShowWeaveInfoMessages(p, true);
+               addXmlConfigFile(p, getProjectRelativePath(p, "p/aop.xml").toString());
+               build(p);
+               checkWasFullBuild();
+               List weaveMessages = getWeavingMessages(p);
+               if (weaveMessages.size() != 1) {
+                       for (Iterator iterator = weaveMessages.iterator(); iterator.hasNext();) {
+                               Object object = (Object) iterator.next();
+                               System.out.println(object);
+                       }
+                       fail("Expected just one weave message.  The aop.xml should have limited the weaving");
+               }
+
+       }
+
        public void testDeclareParentsInModel() {
                String p = "decps";
                initialiseProject(p);