Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

AjdeInteractionTestbed.java 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. /* *******************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement initial implementation
  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.Hashtable;
  17. import java.util.Iterator;
  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.Set;
  21. import junit.framework.AssertionFailedError;
  22. import junit.framework.TestCase;
  23. import org.aspectj.ajde.Ajde;
  24. import org.aspectj.ajde.BuildOptionsAdapter;
  25. import org.aspectj.ajde.BuildProgressMonitor;
  26. import org.aspectj.ajde.ErrorHandler;
  27. import org.aspectj.ajde.ProjectPropertiesAdapter;
  28. import org.aspectj.ajde.TaskListManager;
  29. import org.aspectj.ajdt.internal.core.builder.AbstractStateListener;
  30. import org.aspectj.ajdt.internal.core.builder.AjState;
  31. import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
  32. import org.aspectj.asm.AsmManager;
  33. import org.aspectj.bridge.IMessage;
  34. import org.aspectj.bridge.ISourceLocation;
  35. import org.aspectj.bridge.IMessage.Kind;
  36. /**
  37. * This class uses Ajde in the same way that an IDE (e.g. AJDT) does.
  38. *
  39. * The build is driven through 'build(projectName,configFile)' but the
  40. * build can be configured by the methods beginning 'configure***'.
  41. * Information about what happened during a build is accessible
  42. * through the get*, was*, print* public methods...
  43. *
  44. * There are many methods across the multiple listeners that communicate
  45. * info with Ajde - not all are implemented. Those that are are
  46. * task tagged DOESSOMETHING :)
  47. */
  48. public class AjdeInteractionTestbed extends TestCase {
  49. public static boolean VERBOSE = false; // do you want the gory details?
  50. public static String testdataSrcDir = "../tests/multiIncremental";
  51. protected static File sandboxDir;
  52. private static final String SANDBOX_NAME = "ajcSandbox";
  53. private static boolean buildModel;
  54. // Methods for configuring the build
  55. public static void configureBuildStructureModel(boolean b) { buildModel = b;}
  56. public static void configureNewProjectDependency(String fromProject, String projectItDependsOn) {
  57. MyProjectPropertiesAdapter.addDependancy(fromProject,projectItDependsOn);
  58. }
  59. public static void configureNonStandardCompileOptions(String options) {
  60. MyBuildOptionsAdapter.setNonStandardOptions(options);
  61. }
  62. public static void configureAspectPath(Set aspectpath) {
  63. MyProjectPropertiesAdapter.setAspectpath(aspectpath);
  64. }
  65. // End of methods for configuring the build
  66. protected File getWorkingDir() { return sandboxDir; }
  67. protected void setUp() throws Exception {
  68. super.setUp();
  69. MyStateListener.reset();
  70. MyBuildProgressMonitor.reset();
  71. MyTaskListManager.reset();
  72. MyProjectPropertiesAdapter.reset();
  73. // Create a sandbox in which to work
  74. createEmptySandbox();
  75. }
  76. /** Drives a build */
  77. public boolean build(String projectName,String configFile) {
  78. return AjdeManager.build(projectName,configFile);
  79. }
  80. public boolean fullBuild(String projectName,String configFile) {
  81. return AjdeManager.fullBuild(projectName,configFile);
  82. }
  83. /** Looks after communicating with the singleton Ajde instance */
  84. public static class AjdeManager {
  85. static {
  86. Ajde.init(null,
  87. MyTaskListManager.getInstance(),
  88. MyBuildProgressMonitor.getInstance(),
  89. MyProjectPropertiesAdapter.getInstance(),
  90. MyBuildOptionsAdapter.getInstance(),
  91. null,null,
  92. MyErrorHandler.getInstance());
  93. MyStateListener sl = MyStateListener.getInstance();
  94. AjState.stateListener = sl;
  95. }
  96. /**
  97. * Builds a specified project using a specified config file. Subsequent
  98. * calls to build the same project should result in incremental builds.
  99. */
  100. private static boolean build(String projectName,String configFile) {
  101. pause(1000); // delay to allow previous runs build stamps to be OK
  102. lognoln("Building project '"+projectName+"'");
  103. // Ajde.getDefault().enableLogging(System.out);
  104. //Ajde.getDefault().getBuildManager().setReportInfoMessages(true);
  105. // Configure the necessary providers and listeners for this compile
  106. MyBuildProgressMonitor.reset();
  107. MyTaskListManager.reset();
  108. MyStateListener.reset();
  109. // MyBuildOptionsAdapter.reset(); needs manually resetting in a test
  110. MyProjectPropertiesAdapter.setActiveProject(projectName);
  111. AsmManager.attemptIncrementalModelRepairs=true;
  112. IncrementalStateManager.recordIncrementalStates=true;
  113. Ajde.getDefault().getBuildManager().setBuildModelMode(buildModel);
  114. // Do the compile
  115. Ajde.getDefault().getBuildManager().build(getFile(projectName,configFile));
  116. // Wait for it to complete
  117. while (!MyBuildProgressMonitor.hasFinished()) {
  118. lognoln(".");
  119. pause(100);
  120. }
  121. log("");
  122. // What happened?
  123. if (MyTaskListManager.hasErrorMessages()) {
  124. System.err.println("Build errors:");
  125. for (Iterator iter = MyTaskListManager.getErrorMessages().iterator(); iter.hasNext();) {
  126. IMessage element = (IMessage) iter.next();
  127. System.err.println(element);
  128. }
  129. System.err.println("---------");
  130. }
  131. log("Build finished, time taken = "+MyBuildProgressMonitor.getTimeTaken()+"ms");
  132. return true;
  133. }
  134. private static boolean fullBuild(String projectName,String configFile) {
  135. pause(1000); // delay to allow previous runs build stamps to be OK
  136. lognoln("Building project '"+projectName+"'");
  137. // Ajde.getDefault().enableLogging(System.out);
  138. //Ajde.getDefault().getBuildManager().setReportInfoMessages(true);
  139. // Configure the necessary providers and listeners for this compile
  140. MyBuildProgressMonitor.reset();
  141. MyTaskListManager.reset();
  142. MyStateListener.reset();
  143. MyProjectPropertiesAdapter.setActiveProject(projectName);
  144. //AsmManager.attemptIncrementalModelRepairs=true;
  145. //IncrementalStateManager.recordIncrementalStates=true;
  146. Ajde.getDefault().getBuildManager().setBuildModelMode(buildModel);
  147. // Do the compile
  148. Ajde.getDefault().getBuildManager().buildFresh(getFile(projectName,configFile));
  149. // Wait for it to complete
  150. while (!MyBuildProgressMonitor.hasFinished()) {
  151. lognoln(".");
  152. pause(100);
  153. }
  154. log("");
  155. // What happened?
  156. if (MyTaskListManager.hasErrorMessages()) {
  157. System.err.println("Build errors:");
  158. for (Iterator iter = MyTaskListManager.getErrorMessages().iterator(); iter.hasNext();) {
  159. IMessage element = (IMessage) iter.next();
  160. System.err.println(element);
  161. }
  162. System.err.println("---------");
  163. }
  164. log("Build finished, time taken = "+MyBuildProgressMonitor.getTimeTaken()+"ms");
  165. return true;
  166. }
  167. private static void pause(int millis) {
  168. try {
  169. Thread.sleep(millis);
  170. } catch (InterruptedException ie) {}
  171. }
  172. // public static boolean lastCompileDefaultedToBatch() {
  173. // return MyTaskListManager.defaultedToBatch();
  174. // }
  175. }
  176. // Methods for querying what happened during a build and accessing information
  177. // about the build:
  178. /**
  179. * Helper method for dumping info about which files were compiled and
  180. * woven during the last build.
  181. */
  182. public String printCompiledAndWovenFiles() {
  183. StringBuffer sb = new StringBuffer();
  184. if (getCompiledFiles().size()==0 && getWovenClasses().size()==0)
  185. sb.append("No files were compiled or woven\n");
  186. for (Iterator iter = getCompiledFiles().iterator(); iter.hasNext();) {
  187. Object element = (Object) iter.next();
  188. sb.append("compiled: "+element+"\n");
  189. }
  190. for (Iterator iter = getWovenClasses().iterator(); iter.hasNext();) {
  191. Object element = (Object) iter.next();
  192. sb.append("woven: "+element+"\n");
  193. }
  194. return sb.toString();
  195. }
  196. /**
  197. * Summary report on what happened in the most recent build
  198. */
  199. public void printBuildReport() {
  200. System.out.println("\n============== BUILD REPORT =================");
  201. System.out.println("Build took: "+getTimeTakenForBuild()+"ms");
  202. List compiled=getCompiledFiles();
  203. System.out.println("Compiled: "+compiled.size()+" files");
  204. for (Iterator iter = compiled.iterator(); iter.hasNext();) {
  205. System.out.println(" :"+iter.next());
  206. }
  207. List woven=getWovenClasses();
  208. System.out.println("Wove: "+woven.size()+" files");
  209. for (Iterator iter = woven.iterator(); iter.hasNext();) {
  210. System.out.println(" :"+iter.next());
  211. }
  212. if (wasFullBuild()) System.out.println("It was a batch (full) build");
  213. System.out.println("=============================================");
  214. }
  215. public boolean wasFullBuild() {
  216. return MyStateListener.wasFullBuild();
  217. }
  218. public long getTimeTakenForBuild() {
  219. return MyBuildProgressMonitor.getTimeTaken();
  220. }
  221. public List getCompiledFiles() {
  222. return MyBuildProgressMonitor.getCompiledFiles();
  223. }
  224. public List getWovenClasses() {
  225. return MyBuildProgressMonitor.getWovenClasses();
  226. }
  227. // Infrastructure below here
  228. private void createEmptySandbox() {
  229. String os = System.getProperty("os.name");
  230. File tempDir = null;
  231. // AMC - I did this rather than use the JDK default as I hate having to go look
  232. // in c:\documents and settings\......... for the results of a failed test.
  233. if (os.startsWith("Windows")) {
  234. //Alex: try D first since NTFS on mine while FAT leads to failure..
  235. tempDir = new File("D:\\temp");
  236. if (!tempDir.exists()) {
  237. tempDir = new File("C:\\temp");
  238. if (!tempDir.exists()) {
  239. tempDir.mkdir();
  240. }
  241. }
  242. } else {
  243. tempDir = new File("/tmp");
  244. }
  245. File sandboxRoot = new File(tempDir,SANDBOX_NAME);
  246. if (!sandboxRoot.exists()) {
  247. sandboxRoot.mkdir();
  248. }
  249. org.aspectj.util.FileUtil.deleteContents(sandboxRoot);
  250. try {
  251. sandboxDir = File.createTempFile("ajcTest",".tmp",sandboxRoot);
  252. sandboxDir.delete();
  253. sandboxDir.mkdir();
  254. } catch (IOException ioEx) {
  255. throw new AssertionFailedError("Unable to create sandbox directory for test");
  256. }
  257. }
  258. private static void log(String msg) {
  259. if (VERBOSE) System.out.println(msg);
  260. }
  261. private static void lognoln(String msg) {
  262. if (VERBOSE) System.out.print(msg);
  263. }
  264. /** Return the *full* path to this file which is taken relative to the project dir*/
  265. protected static String getFile(String projectName, String path) {
  266. return new File(sandboxDir,projectName+File.separatorChar + path).getAbsolutePath();
  267. }
  268. // Helper classes that communicate with Ajde
  269. static class MyErrorHandler implements ErrorHandler {
  270. static MyErrorHandler _instance = new MyErrorHandler();
  271. private List errorMessages = new ArrayList();
  272. private MyErrorHandler() {}
  273. public static ErrorHandler getInstance() {
  274. return _instance;
  275. }
  276. public void handleWarning(String message) {
  277. log("ErrorHandler.handleWarning("+message+")");
  278. }
  279. public void handleError(String message) {
  280. log("ErrorHandler.handleWarning("+message+")");
  281. errorMessages.add(message);
  282. }
  283. public void handleError(String message, Throwable t) {
  284. log("ErrorHandler.handleError("+message+","+t+")");
  285. if (VERBOSE) t.printStackTrace();
  286. errorMessages.add(message+","+t+")");
  287. }
  288. public static List/*String*/ getErrorMessages() {
  289. return _instance.errorMessages;
  290. }
  291. }
  292. // -----------------
  293. static class MyProjectPropertiesAdapter implements ProjectPropertiesAdapter {
  294. private final static boolean VERBOSE = false;
  295. static MyProjectPropertiesAdapter _instance = new MyProjectPropertiesAdapter();
  296. private MyProjectPropertiesAdapter() {}
  297. public static ProjectPropertiesAdapter getInstance() {
  298. return _instance;
  299. }
  300. public static void reset() {
  301. _instance.aspectPath=null;
  302. }
  303. private String projectName = null;
  304. private String classPath = "";
  305. private Set aspectPath = null;
  306. public static void setActiveProject(String n) {
  307. _instance.projectName = n;
  308. }
  309. private static Hashtable dependants = new Hashtable();
  310. public static void addDependancy(String project, String projectItDependsOn) {
  311. List l = (List)dependants.get(project);
  312. if (l == null) {
  313. List ps = new ArrayList();
  314. ps.add(projectItDependsOn);
  315. dependants.put(project,ps);
  316. } else {
  317. l.add(projectItDependsOn);
  318. }
  319. }
  320. public void setClasspath(String path) {
  321. this.classPath = path;
  322. }
  323. public static void setAspectpath(Set path) {
  324. _instance.aspectPath = path;
  325. }
  326. // interface impl below
  327. // DOESSOMETHING
  328. public String getProjectName() {
  329. log("MyProjectProperties.getProjectName() [returning "+projectName+"]");
  330. return projectName;
  331. }
  332. // DOESSOMETHING
  333. public String getRootProjectDir() {
  334. String dir = testdataSrcDir+File.separatorChar+projectName;
  335. log("MyProjectProperties.getRootProjectDir() [returning "+dir+"]");
  336. return dir;
  337. }
  338. public List getBuildConfigFiles() {
  339. log("MyProjectProperties.getBuildConfigFiles()");
  340. return null;
  341. }
  342. public String getDefaultBuildConfigFile() {
  343. log("MyProjectProperties.getDefaultBuildConfigFile()");
  344. return null;
  345. }
  346. public String getLastActiveBuildConfigFile() {
  347. log("MyProjectProperties.getLastActiveBuildConfigFile()");
  348. return null;
  349. }
  350. public List getProjectSourceFiles() {
  351. log("MyProjectProperties.getProjectSourceFiles()");
  352. return null;
  353. }
  354. public String getProjectSourcePath() {
  355. log("MyProjectProperties.getProjectSourcePath()");
  356. return null;
  357. }
  358. // DOESSOMETHING
  359. public String getClasspath() {
  360. log("MyProjectProperties.getClasspath()");
  361. String cp =
  362. new File(testdataSrcDir) + File.pathSeparator +
  363. System.getProperty("sun.boot.class.path") +
  364. File.pathSeparator + "../runtime/bin" +
  365. File.pathSeparator + this.classPath +
  366. File.pathSeparator + System.getProperty("aspectjrt.path") +
  367. File.pathSeparator + "../lib/junit/junit.jar" +
  368. File.pathSeparator+".."+File.separator+"lib" + File.separator+"test"+File.separator+"aspectjrt.jar";
  369. // look at dependant projects
  370. List projects = (List)dependants.get(projectName);
  371. if (projects!=null) {
  372. for (Iterator iter = projects.iterator(); iter.hasNext();) {
  373. cp = getFile((String)iter.next(),"bin")+File.pathSeparator+cp;
  374. }
  375. }
  376. //System.err.println("For project "+projectName+" getClasspath() returning "+cp);
  377. return cp;
  378. }
  379. public String getOutputPath() {
  380. String dir = getFile(projectName,"bin");
  381. log("MyProjectProperties.getOutputPath() [returning "+dir+"]");
  382. return dir;
  383. }
  384. public String getBootClasspath() {
  385. log("MyProjectProperties.getBootClasspath()");
  386. return null;
  387. }
  388. public String getClassToExecute() {
  389. log("MyProjectProperties.getClassToExecute()");
  390. return null;
  391. }
  392. public String getExecutionArgs() {
  393. log("MyProjectProperties.getExecutionArgs()");
  394. return null;
  395. }
  396. public String getVmArgs() {
  397. log("MyProjectProperties.getVmArgs()");
  398. return null;
  399. }
  400. public Set getInJars() {
  401. log("MyProjectProperties.getInJars()");
  402. return null;
  403. }
  404. public Set getInpath() {
  405. log("MyProjectProperties.getInPath()");
  406. return null;
  407. }
  408. public Map getSourcePathResources() {
  409. log("MyProjectProperties.getSourcePathResources()");
  410. return null;
  411. }
  412. public String getOutJar() {
  413. log("MyProjectProperties.getOutJar()");
  414. return null;
  415. }
  416. public Set getSourceRoots() {
  417. log("MyProjectProperties.getSourceRoots()");
  418. return null;
  419. }
  420. public Set getAspectPath() {
  421. log("MyProjectProperties.getAspectPath("+aspectPath+")");
  422. return aspectPath;
  423. }
  424. public static void log(String s) {
  425. if (VERBOSE) System.out.println(s);
  426. }
  427. }
  428. // -----------------------
  429. static class MyBuildProgressMonitor implements BuildProgressMonitor {
  430. public static boolean VERBOSE = false;
  431. private static MyBuildProgressMonitor _instance = new MyBuildProgressMonitor();
  432. private MyBuildProgressMonitor() {}
  433. private List compiledFiles=new ArrayList();
  434. private List wovenClasses=new ArrayList();
  435. public static BuildProgressMonitor getInstance() {
  436. return _instance;
  437. }
  438. public static void reset() {
  439. _instance.finished = false;
  440. _instance.compiledFiles.clear();
  441. _instance.wovenClasses.clear();
  442. }
  443. public static boolean hasFinished() {
  444. return _instance.finished;
  445. }
  446. public static List getCompiledFiles() { return _instance.compiledFiles;}
  447. public static List getWovenClasses() { return _instance.wovenClasses; }
  448. //---
  449. private long starttime = 0;
  450. private long totaltimetaken = 0;
  451. private boolean finished = false;
  452. public void start(String configFile) {
  453. starttime = System.currentTimeMillis();
  454. log("BuildProgressMonitor.start("+configFile+")");
  455. }
  456. public void setProgressText(String text) {
  457. log("BuildProgressMonitor.setProgressText("+text+")");
  458. if (text.startsWith("compiled: ")) {
  459. compiledFiles.add(text.substring(10));
  460. } else if (text.startsWith("woven class ")) {
  461. wovenClasses.add(text.substring(12));
  462. } else if (text.startsWith("woven aspect ")) {
  463. wovenClasses.add(text.substring(13));
  464. }
  465. }
  466. public void setProgressBarVal(int newVal) {
  467. log("BuildProgressMonitor.setProgressBarVal("+newVal+")");
  468. }
  469. public void incrementProgressBarVal() {
  470. log("BuildProgressMonitor.incrementProgressBarVal()");
  471. }
  472. public void setProgressBarMax(int maxVal) {
  473. log("BuildProgressMonitor.setProgressBarMax("+maxVal+")");
  474. }
  475. public int getProgressBarMax() {
  476. log("BuildProgressMonitor.getProgressBarMax() [returns 100]");
  477. return 100;
  478. }
  479. public void finish() {
  480. log("BuildProgressMonitor.finish()");
  481. _instance.finished=true;
  482. _instance.totaltimetaken=(System.currentTimeMillis()-starttime);
  483. }
  484. public static long getTimeTaken() {
  485. return _instance.totaltimetaken;
  486. }
  487. public static void log(String s) {
  488. if (VERBOSE) System.out.println(s);
  489. }
  490. }
  491. // ----
  492. static class MyTaskListManager implements TaskListManager {
  493. private static final String CANT_BUILD_INCREMENTAL_INDICATION = "Unable to perform incremental build";
  494. private static final String DOING_BATCH_BUILD_INDICATION = "Performing batch build for config";
  495. private final static boolean VERBOSE = false;
  496. static MyTaskListManager _instance = new MyTaskListManager();
  497. private MyTaskListManager() {}
  498. private boolean receivedNonIncrementalBuildMessage = false;
  499. private boolean receivedBatchBuildMessage = false;
  500. private List errorMessages = new ArrayList();
  501. private List warningMessages = new ArrayList();
  502. private List weavingMessages = new ArrayList();
  503. public static void reset() {
  504. _instance.receivedNonIncrementalBuildMessage=false;
  505. _instance.receivedBatchBuildMessage=false;
  506. _instance.errorMessages.clear();
  507. _instance.warningMessages.clear();
  508. _instance.weavingMessages.clear();
  509. }
  510. // public static boolean defaultedToBatch() {
  511. // return _instance.receivedNonIncrementalBuildMessage;
  512. // }
  513. //
  514. // public static boolean didBatchBuild() {
  515. // return _instance.receivedBatchBuildMessage;
  516. // }
  517. public static boolean hasErrorMessages() {
  518. return !_instance.errorMessages.isEmpty();
  519. }
  520. public static List/*IMessage*/ getErrorMessages() {
  521. return _instance.errorMessages;
  522. }
  523. public static List/*IMessage*/ getWarningMessages() {
  524. return _instance.warningMessages;
  525. }
  526. public static List/*IMessage*/ getWeavingMessages() {
  527. return _instance.weavingMessages;
  528. }
  529. public static TaskListManager getInstance() {
  530. return _instance;
  531. }
  532. public void addSourcelineTask(String message, ISourceLocation sourceLocation, Kind kind) {
  533. log("TaskListManager.addSourcelineTask("+message+","+sourceLocation+","+kind+")");
  534. }
  535. // DOESSOMETHING
  536. public void addSourcelineTask(IMessage message) {
  537. // if (message.getKind()==IMessage.INFO) {
  538. // if (message.getMessage().startsWith(CANT_BUILD_INCREMENTAL_INDICATION)) _instance.receivedNonIncrementalBuildMessage=true;
  539. // if (message.getMessage().startsWith(DOING_BATCH_BUILD_INDICATION)) _instance.receivedBatchBuildMessage=true;
  540. // }
  541. if (message.getKind()==IMessage.ERROR) errorMessages.add(message);
  542. if (message.getKind()==IMessage.WARNING) warningMessages.add(message);
  543. if (message.getKind()==IMessage.WEAVEINFO) weavingMessages.add(message);
  544. log("TaskListManager.addSourcelineTask("+message+")");
  545. }
  546. public boolean hasWarning() {
  547. log("TaskListManager.hasWarning() [returning "+(warningMessages.size()==0)+"]");
  548. return warningMessages.size()==0;
  549. }
  550. public void addProjectTask(String message, Kind kind) {
  551. log("TaskListManager.addProjectTask("+message+","+kind+")");
  552. }
  553. public void clearTasks() {
  554. log("TaskListManager.clearTasks()");
  555. }
  556. public static void log(String s) {
  557. if (VERBOSE) System.out.println(s);
  558. }
  559. }
  560. // ----
  561. static class MyBuildOptionsAdapter implements BuildOptionsAdapter {
  562. static MyBuildOptionsAdapter _instance = new MyBuildOptionsAdapter();
  563. private MyBuildOptionsAdapter() {}
  564. public static void setNonStandardOptions(String options) {
  565. _instance.nonstandardoptions = options;
  566. }
  567. private String nonstandardoptions=null;
  568. public static void reset() {
  569. _instance.nonstandardoptions=null;
  570. }
  571. public static BuildOptionsAdapter getInstance() {
  572. return _instance;
  573. }
  574. public Map getJavaOptionsMap() {
  575. Hashtable ht = new Hashtable();
  576. ht.put("org.eclipse.jdt.core.compiler.compliance","1.5");
  577. ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.5");
  578. return ht;
  579. }
  580. public boolean getUseJavacMode() {
  581. return false;
  582. }
  583. public String getWorkingOutputPath() {
  584. return null;
  585. }
  586. public boolean getPreprocessMode() {
  587. return false;
  588. }
  589. public String getCharacterEncoding() {
  590. return null;
  591. }
  592. public boolean getSourceOnePointFourMode() {
  593. return false;
  594. }
  595. // DOESSOMETHING
  596. public boolean getIncrementalMode() {
  597. return true;
  598. }
  599. public boolean getLenientSpecMode() {
  600. return false;
  601. }
  602. public boolean getStrictSpecMode() {
  603. return false;
  604. }
  605. public boolean getPortingMode() {
  606. return false;
  607. }
  608. public String getNonStandardOptions() {
  609. return nonstandardoptions;
  610. }
  611. public String getComplianceLevel() {
  612. return null;
  613. }
  614. public String getSourceCompatibilityLevel() {
  615. return "1.5";
  616. }
  617. public Set getWarnings() {
  618. return null;
  619. }
  620. public Set getDebugLevel() {
  621. return null;
  622. }
  623. public boolean getNoImportError() {
  624. return false;
  625. }
  626. public boolean getPreserveAllLocals() {
  627. return false;
  628. }
  629. }
  630. static class MyStateListener extends AbstractStateListener {
  631. private static MyStateListener _instance = new MyStateListener();
  632. private MyStateListener() {reset();}
  633. public static MyStateListener getInstance() { return _instance;}
  634. public static boolean informedAboutKindOfBuild;
  635. public static boolean fullBuildOccurred;
  636. public static List detectedDeletions = new ArrayList();
  637. public static void reset() {
  638. informedAboutKindOfBuild=false;
  639. fullBuildOccurred=false;
  640. if (detectedDeletions!=null) detectedDeletions.clear();
  641. }
  642. public boolean pathChange = false;
  643. public void pathChangeDetected() {pathChange = true;}
  644. public void aboutToCompareClasspaths(List oldClasspath, List newClasspath) {}
  645. public void detectedClassChangeInThisDir(File f) {}
  646. public void detectedAspectDeleted(File f) {
  647. detectedDeletions.add(f.toString());
  648. }
  649. public void buildSuccessful(boolean wasFullBuild) {
  650. informedAboutKindOfBuild= true;
  651. fullBuildOccurred=wasFullBuild;
  652. }
  653. public static boolean wasFullBuild() {
  654. if (!informedAboutKindOfBuild) throw new RuntimeException("I never heard about what kind of build it was!!");
  655. return fullBuildOccurred;
  656. }
  657. };
  658. }