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.

MultiProjTestCompilerConfiguration.java 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /********************************************************************
  2. * Copyright (c) 2007 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: IBM Corporation - initial API and implementation
  9. * Helen Hawkins - initial version (bug 148190)
  10. *******************************************************************/
  11. package org.aspectj.systemtest.incremental.tools;
  12. import java.io.File;
  13. import java.util.ArrayList;
  14. import java.util.Hashtable;
  15. import java.util.List;
  16. import java.util.Map;
  17. import java.util.Set;
  18. import org.aspectj.ajde.core.ICompilerConfiguration;
  19. import org.aspectj.ajde.core.IOutputLocationManager;
  20. import org.aspectj.util.LangUtil;
  21. /**
  22. * ICompilerConfiguration which mirrors the way AJDT behaves. Always returns that its 1.5 compliant and enables the setting of all
  23. * options except output jar.
  24. */
  25. public class MultiProjTestCompilerConfiguration implements ICompilerConfiguration {
  26. private boolean verbose = false;
  27. private String classPath = "";
  28. private Set<File> aspectPath = null;
  29. private Map<String,File> sourcePathResources = null;
  30. private IOutputLocationManager outputLocationManager = null;
  31. private List<String> dependants;
  32. private Map<String,String> javaOptionsMap;
  33. private Set<File> inpath;
  34. private String encoding = null;
  35. private String outjar;
  36. private String processor;
  37. private String processorPath;
  38. private String nonstandardoptions;
  39. private List<File> modifiedFiles;
  40. private List<String> modifiedDirs;
  41. private List<String> projectSourceFiles = new ArrayList<>();
  42. private List<String> xmlConfigFiles = new ArrayList<>();
  43. private String projectPath;
  44. int changed;
  45. public MultiProjTestCompilerConfiguration(String projectPath) {
  46. this.projectPath = projectPath;
  47. }
  48. public Set<File> getAspectPath() {
  49. log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")");
  50. return aspectPath;
  51. }
  52. public String getClasspath() {
  53. log("ICompilerConfiguration.getClasspath()");
  54. // AJDT has all the output directories on it's classpath
  55. StringBuffer sb = new StringBuffer();
  56. List<File> allOutputPaths = getOutputLocationManager().getAllOutputLocations();
  57. for (File dir: allOutputPaths) {
  58. sb.append(File.pathSeparator + dir.getAbsolutePath());
  59. }
  60. String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator
  61. + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../runtime/bin" + File.pathSeparator
  62. + this.classPath + File.pathSeparator + System.getProperty("aspectjrt.path") + File.pathSeparator
  63. + "../lib/junit/junit.jar" + "c:/batik/batik-1.6/lib/batik-util.jar;"
  64. + "c:/batik/batik-1.6/lib/batik-awt-util.jar;" + "c:/batik/batik-1.6/lib/batik-dom.jar;"
  65. + "c:/batik/batik-1.6/lib/batik-svggen.jar;" + File.pathSeparator + ".." + File.separator + "lib" + File.separator
  66. + "test" + File.separator + "aspectjrt.jar";
  67. if (LangUtil.is19VMOrGreater()) {
  68. cp = LangUtil.getJrtFsFilePath() + File.pathSeparator + cp;
  69. }
  70. // look at dependant projects
  71. if (dependants != null) {
  72. for (String dependant: dependants) {
  73. cp = AjdeInteractionTestbed.getFile(dependant, "bin") + File.pathSeparator + cp;
  74. }
  75. }
  76. // System.err.println("For project "+projectPath+" getClasspath() returning "+cp);
  77. return cp;
  78. }
  79. public Set<File> getInpath() {
  80. log("ICompilerConfiguration.getInPath()");
  81. return inpath;
  82. }
  83. public Map<String, String> getJavaOptionsMap() {
  84. log("ICompilerConfiguration.getJavaOptionsMap()");
  85. if (javaOptionsMap != null && !javaOptionsMap.isEmpty())
  86. return javaOptionsMap;
  87. Hashtable<String, String> ht = new Hashtable<String, String>();
  88. ht.put("org.eclipse.jdt.core.compiler.compliance", "1.5");
  89. ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.5");
  90. ht.put("org.eclipse.jdt.core.compiler.source", "1.5");
  91. return ht;
  92. }
  93. public String getNonStandardOptions() {
  94. log("ICompilerConfiguration.getNonStandardOptions( " + nonstandardoptions + ")");
  95. return nonstandardoptions;
  96. }
  97. public String getOutJar() {
  98. log("ICompilerConfiguration.getOutJar()");
  99. return null;
  100. }
  101. public IOutputLocationManager getOutputLocationManager() {
  102. log("ICompilerConfiguration.getOutputLocationManager()");
  103. if (outputLocationManager == null) {
  104. outputLocationManager = new MultiProjTestOutputLocationManager(projectPath);
  105. }
  106. return outputLocationManager;
  107. }
  108. public List<String> getProjectSourceFiles() {
  109. log("ICompilerConfiguration.getProjectSourceFiles()");
  110. return projectSourceFiles;
  111. }
  112. public List<String> getProjectXmlConfigFiles() {
  113. return xmlConfigFiles;
  114. }
  115. public List<File> getProjectSourceFilesChanged() {
  116. log("ICompilerConfiguration.getProjectSourceFilesChanged()");
  117. return modifiedFiles;
  118. }
  119. public Map<String,File> getSourcePathResources() {
  120. log("ICompilerConfiguration.getSourcePathResources()");
  121. return sourcePathResources;
  122. }
  123. public void log(String s) {
  124. if (verbose)
  125. System.out.println(s);
  126. }
  127. public void addDependancy(String projectItDependsOn) {
  128. if (dependants == null) {
  129. dependants = new ArrayList<String>();
  130. }
  131. dependants.add(projectItDependsOn);
  132. }
  133. // -------------------- setter methods useful for testing ---------------
  134. public void setAspectPath(Set<File> aspectPath) {
  135. this.aspectPath = aspectPath;
  136. this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED;
  137. }
  138. public void setInpath(Set<File> inpath) {
  139. this.inpath = inpath;
  140. this.changed |= ICompilerConfiguration.INPATH_CHANGED;
  141. }
  142. public void setOutjar(String outjar) {
  143. this.outjar = outjar;
  144. this.changed |= ICompilerConfiguration.OUTJAR_CHANGED;
  145. }
  146. public void setProcessor(String processor) {
  147. this.processor = processor;
  148. this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
  149. }
  150. public void setProcessorPath(String processorPath) {
  151. this.processorPath = processorPath;
  152. this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
  153. }
  154. public void setJavaOptions(Map<String,String> javaOptions) {
  155. this.javaOptionsMap = javaOptions;
  156. this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED;
  157. }
  158. public void setNonStandardOptions(String options) {
  159. this.nonstandardoptions = options;
  160. this.changed |= ICompilerConfiguration.NONSTANDARDOPTIONS_CHANGED;
  161. }
  162. public void setProjectSourceFiles(List<String> projectSourceFiles) {
  163. this.projectSourceFiles = projectSourceFiles;
  164. this.changed |= ICompilerConfiguration.PROJECTSOURCEFILES_CHANGED;
  165. }
  166. public void setProjectXmlConfigFiles(List<String> xmlConfigFiles) {
  167. this.xmlConfigFiles = xmlConfigFiles;
  168. this.changed |= ICompilerConfiguration.XMLCONFIG_CHANGED;
  169. }
  170. public void addProjectSourceFileChanged(File f) {
  171. if (this.modifiedFiles == null) {
  172. this.modifiedFiles = new ArrayList<File>();
  173. }
  174. if (f != null) {
  175. modifiedFiles.add(f);
  176. }
  177. }
  178. public void addClasspathEntryChanged(String f) {
  179. if (this.modifiedDirs == null) {
  180. this.modifiedDirs = new ArrayList<String>();
  181. }
  182. if (f != null) {
  183. modifiedDirs.add(f);
  184. }
  185. }
  186. public void setSourcePathResources(Map<String,File> sourcePathResources) {
  187. this.sourcePathResources = sourcePathResources;
  188. this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED;
  189. }
  190. public void setOutputLocationManager(IOutputLocationManager manager) {
  191. this.outputLocationManager = manager;
  192. }
  193. public void setClasspath(String path) {
  194. this.classPath = path;
  195. this.changed |= ICompilerConfiguration.CLASSPATH_CHANGED;
  196. }
  197. public int getConfigurationChanges() {
  198. return changed;
  199. // return EVERYTHING;
  200. }
  201. public void configurationRead() {
  202. changed = NO_CHANGES;
  203. modifiedFiles = null;
  204. modifiedDirs = null;
  205. }
  206. public List<String> getClasspathElementsWithModifiedContents() {
  207. return modifiedDirs;
  208. }
  209. public void setProjectEncoding(String encoding) {
  210. this.encoding = encoding;
  211. }
  212. public String getProjectEncoding() {
  213. return this.encoding;
  214. }
  215. public String getProcessor() {
  216. return this.processor;
  217. }
  218. public String getProcessorPath() {
  219. return this.processorPath;
  220. }
  221. @Override
  222. public String getModulepath() {
  223. return null;
  224. }
  225. @Override
  226. public String getModuleSourcepath() {
  227. return null;
  228. }
  229. }