Browse Source

124460: aop.xml used for compilation: AJDT interface support

tags/pre268419
aclement 15 years ago
parent
commit
41e23851e2

+ 3
- 3
tests/src/org/aspectj/systemtest/ajc164/ajc164.xml View 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)"/>
@@ -11,14 +11,14 @@
</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>

+ 50
- 0
tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java View 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
*/

+ 10
- 0
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java View 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();

+ 20
- 0
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java View 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);

Loading…
Cancel
Save