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.3KB

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