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
8 * Contributors: IBM Corporation - initial API and implementation
9 * Helen Hawkins - initial version (bug 148190)
10 *******************************************************************/
11 package org.aspectj.systemtest.incremental.tools;
14 import java.util.ArrayList;
15 import java.util.Hashtable;
16 import java.util.List;
20 import org.aspectj.ajde.core.ICompilerConfiguration;
21 import org.aspectj.ajde.core.IOutputLocationManager;
22 import org.aspectj.util.LangUtil;
25 * ICompilerConfiguration which mirrors the way AJDT behaves. Always returns that its 1.5 compliant and enables the setting of all
26 * options except output jar.
28 public class MultiProjTestCompilerConfiguration implements ICompilerConfiguration {
30 private boolean verbose = false;
32 private String classPath = "";
33 private Set<File> aspectPath = null;
34 private Map<String,File> sourcePathResources = null;
35 private IOutputLocationManager outputLocationManager = null;
36 private List<String> dependants;
37 private Map<String,String> javaOptionsMap;
38 private Set<File> inpath;
39 private String encoding = null;
40 private String outjar;
41 private String processor;
42 private String processorPath;
43 private String nonstandardoptions;
44 private List<File> modifiedFiles;
45 private List<String> modifiedDirs;
46 private List<String> projectSourceFiles = new ArrayList<>();
47 private List<String> xmlConfigFiles = new ArrayList<>();
48 private String projectPath;
52 public MultiProjTestCompilerConfiguration(String projectPath) {
53 this.projectPath = projectPath;
56 public Set<File> getAspectPath() {
57 log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")");
61 public String getClasspath() {
62 log("ICompilerConfiguration.getClasspath()");
63 // AJDT has all the output directories on it's classpath
64 StringBuffer sb = new StringBuffer();
65 List<File> allOutputPaths = getOutputLocationManager().getAllOutputLocations();
66 for (File dir: allOutputPaths) {
67 sb.append(File.pathSeparator + dir.getAbsolutePath());
69 String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator
70 + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../runtime/bin" + File.pathSeparator
71 + this.classPath + File.pathSeparator + System.getProperty("aspectjrt.path") + File.pathSeparator
72 + "../lib/junit/junit.jar" + "c:/batik/batik-1.6/lib/batik-util.jar;"
73 + "c:/batik/batik-1.6/lib/batik-awt-util.jar;" + "c:/batik/batik-1.6/lib/batik-dom.jar;"
74 + "c:/batik/batik-1.6/lib/batik-svggen.jar;" + File.pathSeparator + ".." + File.separator + "lib" + File.separator
75 + "test" + File.separator + "aspectjrt.jar";
76 if (LangUtil.is19VMOrGreater()) {
77 cp = LangUtil.getJrtFsFilePath() + File.pathSeparator + cp;
80 // look at dependant projects
81 if (dependants != null) {
82 for (String dependant: dependants) {
83 cp = AjdeInteractionTestbed.getFile(dependant, "bin") + File.pathSeparator + cp;
86 // System.err.println("For project "+projectPath+" getClasspath() returning "+cp);
90 public Set<File> getInpath() {
91 log("ICompilerConfiguration.getInPath()");
95 public Map<String, String> getJavaOptionsMap() {
96 log("ICompilerConfiguration.getJavaOptionsMap()");
97 if (javaOptionsMap != null && !javaOptionsMap.isEmpty())
98 return javaOptionsMap;
100 Hashtable<String, String> ht = new Hashtable<String, String>();
101 ht.put("org.eclipse.jdt.core.compiler.compliance", "1.5");
102 ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.5");
103 ht.put("org.eclipse.jdt.core.compiler.source", "1.5");
107 public String getNonStandardOptions() {
108 log("ICompilerConfiguration.getNonStandardOptions( " + nonstandardoptions + ")");
109 return nonstandardoptions;
112 public String getOutJar() {
113 log("ICompilerConfiguration.getOutJar()");
117 public IOutputLocationManager getOutputLocationManager() {
118 log("ICompilerConfiguration.getOutputLocationManager()");
119 if (outputLocationManager == null) {
120 outputLocationManager = new MultiProjTestOutputLocationManager(projectPath);
122 return outputLocationManager;
125 public List<String> getProjectSourceFiles() {
126 log("ICompilerConfiguration.getProjectSourceFiles()");
127 return projectSourceFiles;
130 public List<String> getProjectXmlConfigFiles() {
131 return xmlConfigFiles;
134 public List<File> getProjectSourceFilesChanged() {
135 log("ICompilerConfiguration.getProjectSourceFilesChanged()");
136 return modifiedFiles;
139 public Map<String,File> getSourcePathResources() {
140 log("ICompilerConfiguration.getSourcePathResources()");
141 return sourcePathResources;
144 public void log(String s) {
146 System.out.println(s);
149 public void addDependancy(String projectItDependsOn) {
150 if (dependants == null) {
151 dependants = new ArrayList<String>();
153 dependants.add(projectItDependsOn);
156 // -------------------- setter methods useful for testing ---------------
157 public void setAspectPath(Set<File> aspectPath) {
158 this.aspectPath = aspectPath;
159 this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED;
162 public void setInpath(Set<File> inpath) {
163 this.inpath = inpath;
164 this.changed |= ICompilerConfiguration.INPATH_CHANGED;
167 public void setOutjar(String outjar) {
168 this.outjar = outjar;
169 this.changed |= ICompilerConfiguration.OUTJAR_CHANGED;
172 public void setProcessor(String processor) {
173 this.processor = processor;
174 this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
177 public void setProcessorPath(String processorPath) {
178 this.processorPath = processorPath;
179 this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
182 public void setJavaOptions(Map<String,String> javaOptions) {
183 this.javaOptionsMap = javaOptions;
184 this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED;
187 public void setNonStandardOptions(String options) {
188 this.nonstandardoptions = options;
189 this.changed |= ICompilerConfiguration.NONSTANDARDOPTIONS_CHANGED;
192 public void setProjectSourceFiles(List<String> projectSourceFiles) {
193 this.projectSourceFiles = projectSourceFiles;
194 this.changed |= ICompilerConfiguration.PROJECTSOURCEFILES_CHANGED;
197 public void setProjectXmlConfigFiles(List<String> xmlConfigFiles) {
198 this.xmlConfigFiles = xmlConfigFiles;
199 this.changed |= ICompilerConfiguration.XMLCONFIG_CHANGED;
202 public void addProjectSourceFileChanged(File f) {
203 if (this.modifiedFiles == null) {
204 this.modifiedFiles = new ArrayList<File>();
207 modifiedFiles.add(f);
211 public void addClasspathEntryChanged(String f) {
212 if (this.modifiedDirs == null) {
213 this.modifiedDirs = new ArrayList<String>();
220 public void setSourcePathResources(Map<String,File> sourcePathResources) {
221 this.sourcePathResources = sourcePathResources;
222 this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED;
225 public void setOutputLocationManager(IOutputLocationManager manager) {
226 this.outputLocationManager = manager;
229 public void setClasspath(String path) {
230 this.classPath = path;
231 this.changed |= ICompilerConfiguration.CLASSPATH_CHANGED;
234 public int getConfigurationChanges() {
236 // return EVERYTHING;
239 public void configurationRead() {
240 changed = NO_CHANGES;
241 modifiedFiles = null;
245 public List<String> getClasspathElementsWithModifiedContents() {
249 public void setProjectEncoding(String encoding) {
250 this.encoding = encoding;
253 public String getProjectEncoding() {
254 return this.encoding;
257 public String getProcessor() {
258 return this.processor;
261 public String getProcessorPath() {
262 return this.processorPath;
266 public String getModulepath() {
271 public String getModuleSourcepath() {