You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AjdeInteractionTestbed.java 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /********************************************************************
  2. * Copyright (c) 2005 Contributors.All rights reserved.
  3. * This program and the accompanying materials are made available
  4. * under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution and is available at
  6. * http://eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement initial implementation
  10. * Helen Hawkins Converted to new interface (bug 148190)
  11. *******************************************************************/
  12. package org.aspectj.systemtest.incremental.tools;
  13. import java.io.File;
  14. import java.io.IOException;
  15. import java.util.ArrayList;
  16. import java.util.HashSet;
  17. import java.util.Iterator;
  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.Set;
  21. import org.aspectj.ajde.core.AjCompiler;
  22. import org.aspectj.ajde.core.IBuildMessageHandler;
  23. import org.aspectj.ajde.core.ICompilerConfiguration;
  24. import org.aspectj.ajde.core.IOutputLocationManager;
  25. import org.aspectj.ajdt.internal.core.builder.AbstractStateListener;
  26. import org.aspectj.ajdt.internal.core.builder.AjState;
  27. import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
  28. import org.aspectj.asm.AsmManager;
  29. import org.aspectj.bridge.IMessage;
  30. import org.aspectj.testing.util.TestUtil;
  31. import junit.framework.TestCase;
  32. /**
  33. * This class uses Ajde in the same way that an IDE (e.g. AJDT) does.
  34. *
  35. * The build is driven through 'doBuild(projectName)' but the build can be configured by the methods beginning 'configure***'.
  36. * Information about what happened during a build is accessible through the get*, was*, print* public methods...
  37. *
  38. */
  39. public class AjdeInteractionTestbed extends TestCase {
  40. public static boolean VERBOSE = false; // do you want the gory details?
  41. public static String testdataSrcDir = "../tests/multiIncremental";
  42. protected static File sandboxDir;
  43. private static boolean buildModel;
  44. // Methods for configuring the build
  45. public void configureNewProjectDependency(String fromProjectName, String projectItDependsOn) {
  46. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + fromProjectName);
  47. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addDependancy(projectItDependsOn);
  48. }
  49. public void addSourceFolderForSourceFile(String projectName, File f, String sourceFolder) {
  50. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  51. ((MultiProjTestOutputLocationManager) ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration())
  52. .getOutputLocationManager()).setSourceFolderFor(f, sourceFolder);
  53. }
  54. public void setNextChangeResponse(String projName, int flags) {
  55. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projName);
  56. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).changed = flags;
  57. }
  58. public void setProjectEncoding(String projName, String encoding) {
  59. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projName);
  60. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProjectEncoding(encoding);
  61. }
  62. public void addProjectSourceFileChanged(String projectName, File changedFile) {
  63. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  64. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addProjectSourceFileChanged(changedFile);
  65. }
  66. public void addXmlConfigFile(String projectName, String xmlfile) {
  67. List<String> l = new ArrayList<String>();
  68. l.add(xmlfile);
  69. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  70. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProjectXmlConfigFiles(l);
  71. }
  72. public void addClasspathEntry(String projectName, File classpathEntry) {
  73. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  74. MultiProjTestCompilerConfiguration config = ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration());
  75. config.setClasspath(config.getClasspath() + File.pathSeparator + classpathEntry.toString());
  76. }
  77. public void addClasspathEntryChanged(String projectName, String changedDir) {
  78. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  79. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addClasspathEntryChanged(changedDir);
  80. }
  81. public void configureNonStandardCompileOptions(String projectName, String options) {
  82. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  83. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setNonStandardOptions(options);
  84. }
  85. public void configureAspectPath(String projectName, Set<File> aspectpath) {
  86. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  87. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(aspectpath);
  88. }
  89. public void configureProcessor(String projectName, String processor) {
  90. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  91. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProcessor(processor);
  92. }
  93. public void configureProcessorPath(String projectName, String processorPath) {
  94. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  95. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProcessorPath(processorPath);
  96. }
  97. public void configureAspectPath(String projectName, File aspectpath) {
  98. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  99. Set<File> s = new HashSet<File>();
  100. s.add(aspectpath);
  101. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(s);
  102. }
  103. public void configureResourceMap(String projectName, Map<String,File> resourcesMap) {
  104. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  105. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setSourcePathResources(resourcesMap);
  106. }
  107. public void configureJavaOptionsMap(String projectName, Map<String,String> options) {
  108. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  109. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setJavaOptions(options);
  110. }
  111. public static void configureInPath(String projectName, Set<File> inpath) {
  112. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  113. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setInpath(inpath);
  114. }
  115. public static void configureInPath(String projectName, File inpath) {
  116. Set<File> s = new HashSet<File>();
  117. s.add(inpath);
  118. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  119. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setInpath(s);
  120. }
  121. public static void configureOutputLocationManager(String projectName, IOutputLocationManager mgr) {
  122. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  123. ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setOutputLocationManager(mgr);
  124. }
  125. public void configureShowWeaveInfoMessages(String projectName, boolean showWeaveInfo) {
  126. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  127. IBuildMessageHandler handler = compiler.getMessageHandler();
  128. if (showWeaveInfo) {
  129. handler.dontIgnore(IMessage.WEAVEINFO);
  130. } else {
  131. handler.ignore(IMessage.WEAVEINFO);
  132. }
  133. }
  134. // End of methods for configuring the build
  135. public AjCompiler getCompilerForProjectWithName(String projectName) {
  136. return CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  137. }
  138. protected File getWorkingDir() {
  139. return sandboxDir;
  140. }
  141. protected void setUp() throws Exception {
  142. super.setUp();
  143. // need this line because otherwise reset in previous tests
  144. AsmManager.attemptIncrementalModelRepairs = true;
  145. if (AjState.stateListener == null) {
  146. AjState.stateListener = MyStateListener.getInstance();
  147. }
  148. MyStateListener.reset();
  149. // Create a sandbox in which to work
  150. sandboxDir = TestUtil.createEmptySandbox();
  151. }
  152. protected void tearDown() throws Exception {
  153. super.tearDown();
  154. AjState.stateListener = null;
  155. CompilerFactory.clearCompilerMap();
  156. IncrementalStateManager.clearIncrementalStates();
  157. }
  158. /** Drives a build */
  159. public boolean doBuild(String projectName) {
  160. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  161. resetCompilerRecords(compiler);
  162. addSourceFilesToBuild(projectName, compiler);
  163. // addXmlConfigFilesToBuild(projectName, compiler);
  164. pause(1000); // delay to allow previous runs build stamps to be OK
  165. lognoln("Building project '" + projectName + "'");
  166. compiler.build();
  167. log("");
  168. checkForErrors(compiler);
  169. log("Build finished, time taken = "
  170. + ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getTimeTaken() + "ms");
  171. return true;
  172. }
  173. // public AsmManager getStructureModelFor(String projectName) {
  174. // AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  175. // returnc compiler.getStructureModelFor(projectName)
  176. // }
  177. /** Drives a full build **/
  178. public boolean doFullBuild(String projectName) {
  179. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  180. resetCompilerRecords(compiler);
  181. addSourceFilesToBuild(projectName, compiler);
  182. addXmlConfigFilesToBuild(projectName, compiler);
  183. pause(1000); // delay to allow previous runs build stamps to be OK
  184. lognoln("Building project '" + projectName + "'");
  185. compiler.buildFresh();
  186. log("");
  187. checkForErrors(compiler);
  188. log("Build finished, time taken = "
  189. + ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getTimeTaken() + "ms");
  190. return true;
  191. }
  192. /**
  193. * Clears any maps associated with the compiler
  194. */
  195. private void resetCompilerRecords(AjCompiler compiler) {
  196. ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).reset();
  197. ((MultiProjTestMessageHandler) compiler.getMessageHandler()).reset();
  198. }
  199. /**
  200. * Find the source files associated with the given project and add them to the list of projectSourceFiles in the
  201. * MultiProjTestCompilerConfiguration to be used in the subsequent build
  202. */
  203. private void addSourceFilesToBuild(String pname, AjCompiler compiler) {
  204. File projectBase = new File(sandboxDir, pname);
  205. ICompilerConfiguration icc = compiler.getCompilerConfiguration();
  206. List<String> currentFiles = icc.getProjectSourceFiles();
  207. List<String> filesForCompilation = new ArrayList<String>();
  208. collectUpFiles(projectBase, projectBase, filesForCompilation);
  209. boolean changed = false;
  210. for (String s : filesForCompilation) {
  211. if (!currentFiles.contains(s)) {
  212. changed = true;
  213. }
  214. }
  215. for (String currentFile : currentFiles) {
  216. if (!filesForCompilation.contains(currentFile)) {
  217. changed = true;
  218. }
  219. }
  220. if (changed) {
  221. ((MultiProjTestCompilerConfiguration) icc).setProjectSourceFiles(filesForCompilation);
  222. }
  223. }
  224. private void addXmlConfigFilesToBuild(String pname, AjCompiler compiler) {
  225. File projectBase = new File(sandboxDir, pname);
  226. ICompilerConfiguration icc = compiler.getCompilerConfiguration();
  227. List<String> currentXmlFiles = icc.getProjectXmlConfigFiles();
  228. List<String> collector = new ArrayList<String>();
  229. collectUpXmlFiles(projectBase, projectBase, collector);
  230. boolean changed = false;
  231. for (String s : collector) {
  232. if (!currentXmlFiles.contains(s)) {
  233. changed = true;
  234. }
  235. }
  236. for (String currentXmlFile : currentXmlFiles) {
  237. if (!collector.contains(currentXmlFile)) {
  238. changed = true;
  239. }
  240. }
  241. if (changed) {
  242. ((MultiProjTestCompilerConfiguration) icc).setProjectXmlConfigFiles(collector);
  243. }
  244. }
  245. private void collectUpFiles(File location, File base, List<String> collectionPoint) {
  246. String contents[] = location.list();
  247. if (contents == null) {
  248. return;
  249. }
  250. for (String string : contents) {
  251. File f = new File(location, string);
  252. if (f.isDirectory()) {
  253. collectUpFiles(f, base, collectionPoint);
  254. } else if (f.isFile() && (f.getName().endsWith(".aj") || f.getName().endsWith(".java"))) {
  255. String fileFound;
  256. try {
  257. fileFound = f.getCanonicalPath();
  258. collectionPoint.add(fileFound);
  259. // String toRemove = base.getCanonicalPath();
  260. // if (!fileFound.startsWith(toRemove)) throw new RuntimeException("eh? "+fileFound+" "+toRemove);
  261. // collectionPoint.add(fileFound.substring(toRemove.length()+1));//+1 captures extra separator
  262. } catch (IOException e) {
  263. e.printStackTrace();
  264. }
  265. }
  266. }
  267. }
  268. private void collectUpXmlFiles(File location, File base, List<String> collectionPoint) {
  269. String contents[] = location.list();
  270. if (contents == null) {
  271. return;
  272. }
  273. for (String string : contents) {
  274. File f = new File(location, string);
  275. if (f.isDirectory()) {
  276. collectUpXmlFiles(f, base, collectionPoint);
  277. } else if (f.isFile() && f.getName().endsWith(".xml")) {
  278. String fileFound;
  279. try {
  280. fileFound = f.getCanonicalPath();
  281. collectionPoint.add(fileFound);
  282. } catch (IOException e) {
  283. e.printStackTrace();
  284. }
  285. }
  286. }
  287. }
  288. /**
  289. * Make sure no errors have been recorded
  290. */
  291. private void checkForErrors(AjCompiler compiler) {
  292. MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler();
  293. if (handler.hasErrorMessages()) {
  294. System.err.println("Build errors:");
  295. for (IMessage message: handler.getErrorMessages()) {
  296. System.err.println(message);
  297. }
  298. System.err.println("---------");
  299. }
  300. }
  301. public List<IMessage> getErrorMessages(String projectName) {
  302. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  303. return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getErrorMessages();
  304. }
  305. public List<IMessage> getWarningMessages(String projectName) {
  306. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  307. return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWarningMessages();
  308. }
  309. public List<IMessage> getWeavingMessages(String projectName) {
  310. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  311. return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWeavingMessages();
  312. }
  313. public List<String> getCompilerErrorMessages(String projectName) {
  314. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  315. return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getCompilerErrors();
  316. }
  317. public void checkForError(String projectName, String anError) {
  318. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  319. List<IMessage> messages = ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getErrorMessages();
  320. for (IMessage element : messages) {
  321. if (element.getMessage().contains(anError)) {
  322. return;
  323. }
  324. }
  325. fail("Didn't find the error message:\n'" + anError + "'.\nErrors that occurred:\n" + messages);
  326. }
  327. private void pause(int millis) {
  328. try {
  329. Thread.sleep(millis);
  330. } catch (InterruptedException ie) {
  331. }
  332. }
  333. // Methods for querying what happened during a build and accessing information
  334. // about the build:
  335. /**
  336. * Helper method for dumping info about which files were compiled and woven during the last build.
  337. */
  338. public String printCompiledAndWovenFiles(String projectName) {
  339. StringBuffer sb = new StringBuffer();
  340. if (getCompiledFiles(projectName).size() == 0 && getWovenClasses(projectName).size() == 0) {
  341. sb.append("No files were compiled or woven\n");
  342. }
  343. for (String element: getCompiledFiles(projectName)) {
  344. sb.append("compiled: " + element + "\n");
  345. }
  346. for (String element: getWovenClasses(projectName)) {
  347. sb.append("woven: " + element + "\n");
  348. }
  349. return sb.toString();
  350. }
  351. /**
  352. * Summary report on what happened in the most recent build
  353. */
  354. public void printBuildReport(String projectName) {
  355. System.out.println("\n====== BUILD REPORT (Project " + projectName + ") ===========");
  356. System.out.println("Build took: " + getTimeTakenForBuild(projectName) + "ms");
  357. List<String> compiled = getCompiledFiles(projectName);
  358. System.out.println("Compiled: " + compiled.size() + " files");
  359. for (String value : compiled) {
  360. System.out.println(" :" + value);
  361. }
  362. List<String> woven = getWovenClasses(projectName);
  363. System.out.println("Wove: " + woven.size() + " files");
  364. for (String s : woven) {
  365. System.out.println(" :" + s);
  366. }
  367. if (wasFullBuild()) {
  368. System.out.println("It was a batch (full) build");
  369. }
  370. System.out.println("=============================================");
  371. }
  372. /**
  373. * Check we compiled/wove the right number of files, passing '-1' indicates you don't care about that number.
  374. */
  375. public void checkCompileWeaveCount(String projectName, int expCompile, int expWoven) {
  376. if (expCompile != -1 && getCompiledFiles(projectName).size() != expCompile) {
  377. fail("Expected compilation of " + expCompile + " files but compiled " + getCompiledFiles(projectName).size() + "\n"
  378. + printCompiledAndWovenFiles(projectName));
  379. }
  380. if (expWoven != -1 && getWovenClasses(projectName).size() != expWoven) {
  381. fail("Expected weaving of " + expWoven + " files but wove " + getWovenClasses(projectName).size() + "\n"
  382. + printCompiledAndWovenFiles(projectName));
  383. }
  384. }
  385. public void checkWasntFullBuild() {
  386. assertTrue("Shouldn't have been a full (batch) build", !wasFullBuild());
  387. }
  388. public void checkWasFullBuild() {
  389. assertTrue("Should have been a full (batch) build", wasFullBuild());
  390. }
  391. public boolean wasFullBuild() {
  392. // alternatives: statelistener is debug interface, progressmonitor is new proper interface (see pr145689)
  393. // return MyBuildProgressMonitor.wasFullBuild();
  394. return MyStateListener.wasFullBuild();
  395. }
  396. public long getTimeTakenForBuild(String projectName) {
  397. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  398. return ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getTimeTaken();
  399. }
  400. public List<String> getCompiledFiles(String projectName) {
  401. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  402. return ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getCompiledFiles();
  403. }
  404. public AsmManager getModelFor(String projectName) {
  405. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  406. return compiler.getModel();
  407. }
  408. public List<String> getWovenClasses(String projectName) {
  409. AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
  410. return ((MultiProjTestBuildProgressMonitor) compiler.getBuildProgressMonitor()).getWovenClasses();
  411. }
  412. // Infrastructure below here
  413. private static void log(String msg) {
  414. if (VERBOSE) {
  415. System.out.println(msg);
  416. }
  417. }
  418. private static void lognoln(String msg) {
  419. if (VERBOSE) {
  420. System.out.print(msg);
  421. }
  422. }
  423. /** Return the *full* path to this file which is taken relative to the project dir */
  424. protected static String getFile(String projectName, String path) {
  425. return new File(sandboxDir, projectName + File.separatorChar + path).getAbsolutePath();
  426. }
  427. static class MyStateListener extends AbstractStateListener {
  428. private static MyStateListener _instance = new MyStateListener();
  429. private MyStateListener() {
  430. reset();
  431. }
  432. public static MyStateListener getInstance() {
  433. return _instance;
  434. }
  435. public static boolean informedAboutKindOfBuild;
  436. public static boolean fullBuildOccurred;
  437. public static List<String> detectedDeletions = new ArrayList<String>();
  438. public static StringBuffer decisions = new StringBuffer();
  439. public static void reset() {
  440. informedAboutKindOfBuild = false;
  441. decisions = new StringBuffer();
  442. fullBuildOccurred = false;
  443. if (detectedDeletions != null) {
  444. detectedDeletions.clear();
  445. }
  446. }
  447. public boolean pathChange = false;
  448. public void pathChangeDetected() {
  449. pathChange = true;
  450. }
  451. public void aboutToCompareClasspaths(List oldClasspath, List newClasspath) {
  452. }
  453. public void detectedClassChangeInThisDir(File f) {
  454. recordDecision("Detected class change in this directory: " + f.toString());
  455. }
  456. public void detectedAspectDeleted(File f) {
  457. detectedDeletions.add(f.toString());
  458. }
  459. public void buildSuccessful(boolean wasFullBuild) {
  460. informedAboutKindOfBuild = true;
  461. fullBuildOccurred = wasFullBuild;
  462. }
  463. public static String getDecisions() {
  464. return decisions.toString();
  465. }
  466. public static boolean wasFullBuild() {
  467. if (!informedAboutKindOfBuild) {
  468. throw new RuntimeException("I never heard about what kind of build it was!!");
  469. }
  470. return fullBuildOccurred;
  471. }
  472. // not needed just yet...
  473. // public void recordInformation(String s) { decisions.append(s).append("\n");}
  474. public void recordDecision(String s) {
  475. decisions.append(s).append("\n");
  476. log(s);
  477. }
  478. };
  479. }