]> source.dussan.org Git - aspectj.git/blob
cd80218b2636b756bdaf703e90897b9c8c8574d7
[aspectj.git] /
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
13 import java.io.File;
14 import java.util.ArrayList;
15 import java.util.Hashtable;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.Set;
19
20 import org.aspectj.ajde.core.ICompilerConfiguration;
21 import org.aspectj.ajde.core.IOutputLocationManager;
22 import org.aspectj.util.LangUtil;
23
24 /**
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.
27  */
28 public class MultiProjTestCompilerConfiguration implements ICompilerConfiguration {
29
30         private boolean verbose = false;
31
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;
49
50         int changed;
51
52         public MultiProjTestCompilerConfiguration(String projectPath) {
53                 this.projectPath = projectPath;
54         }
55
56         public Set<File> getAspectPath() {
57                 log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")");
58                 return aspectPath;
59         }
60
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());
68                 }
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;
78                 }
79
80                 // look at dependant projects
81                 if (dependants != null) {
82                         for (String dependant: dependants) {
83                                 cp = AjdeInteractionTestbed.getFile(dependant, "bin") + File.pathSeparator + cp;
84                         }
85                 }
86                 // System.err.println("For project "+projectPath+" getClasspath() returning "+cp);
87                 return cp;
88         }
89
90         public Set<File> getInpath() {
91                 log("ICompilerConfiguration.getInPath()");
92                 return inpath;
93         }
94
95         public Map<String, String> getJavaOptionsMap() {
96                 log("ICompilerConfiguration.getJavaOptionsMap()");
97                 if (javaOptionsMap != null && !javaOptionsMap.isEmpty())
98                         return javaOptionsMap;
99
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");
104                 return ht;
105         }
106
107         public String getNonStandardOptions() {
108                 log("ICompilerConfiguration.getNonStandardOptions( " + nonstandardoptions + ")");
109                 return nonstandardoptions;
110         }
111
112         public String getOutJar() {
113                 log("ICompilerConfiguration.getOutJar()");
114                 return null;
115         }
116
117         public IOutputLocationManager getOutputLocationManager() {
118                 log("ICompilerConfiguration.getOutputLocationManager()");
119                 if (outputLocationManager == null) {
120                         outputLocationManager = new MultiProjTestOutputLocationManager(projectPath);
121                 }
122                 return outputLocationManager;
123         }
124
125         public List<String> getProjectSourceFiles() {
126                 log("ICompilerConfiguration.getProjectSourceFiles()");
127                 return projectSourceFiles;
128         }
129
130         public List<String> getProjectXmlConfigFiles() {
131                 return xmlConfigFiles;
132         }
133
134         public List<File> getProjectSourceFilesChanged() {
135                 log("ICompilerConfiguration.getProjectSourceFilesChanged()");
136                 return modifiedFiles;
137         }
138
139         public Map<String,File> getSourcePathResources() {
140                 log("ICompilerConfiguration.getSourcePathResources()");
141                 return sourcePathResources;
142         }
143
144         public void log(String s) {
145                 if (verbose)
146                         System.out.println(s);
147         }
148
149         public void addDependancy(String projectItDependsOn) {
150                 if (dependants == null) {
151                         dependants = new ArrayList<String>();
152                 }
153                 dependants.add(projectItDependsOn);
154         }
155
156         // -------------------- setter methods useful for testing ---------------
157         public void setAspectPath(Set<File> aspectPath) {
158                 this.aspectPath = aspectPath;
159                 this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED;
160         }
161
162         public void setInpath(Set<File> inpath) {
163                 this.inpath = inpath;
164                 this.changed |= ICompilerConfiguration.INPATH_CHANGED;
165         }
166
167         public void setOutjar(String outjar) {
168                 this.outjar = outjar;
169                 this.changed |= ICompilerConfiguration.OUTJAR_CHANGED;
170         }
171         
172         public void setProcessor(String processor) {
173                 this.processor = processor;
174                 this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
175         }
176
177         public void setProcessorPath(String processorPath) {
178                 this.processorPath = processorPath;
179                 this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
180         }
181
182         public void setJavaOptions(Map<String,String> javaOptions) {
183                 this.javaOptionsMap = javaOptions;
184                 this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED;
185         }
186
187         public void setNonStandardOptions(String options) {
188                 this.nonstandardoptions = options;
189                 this.changed |= ICompilerConfiguration.NONSTANDARDOPTIONS_CHANGED;
190         }
191
192         public void setProjectSourceFiles(List<String> projectSourceFiles) {
193                 this.projectSourceFiles = projectSourceFiles;
194                 this.changed |= ICompilerConfiguration.PROJECTSOURCEFILES_CHANGED;
195         }
196
197         public void setProjectXmlConfigFiles(List<String> xmlConfigFiles) {
198                 this.xmlConfigFiles = xmlConfigFiles;
199                 this.changed |= ICompilerConfiguration.XMLCONFIG_CHANGED;
200         }
201
202         public void addProjectSourceFileChanged(File f) {
203                 if (this.modifiedFiles == null) {
204                         this.modifiedFiles = new ArrayList<File>();
205                 }
206                 if (f != null) {
207                         modifiedFiles.add(f);
208                 }
209         }
210
211         public void addClasspathEntryChanged(String f) {
212                 if (this.modifiedDirs == null) {
213                         this.modifiedDirs = new ArrayList<String>();
214                 }
215                 if (f != null) {
216                         modifiedDirs.add(f);
217                 }
218         }
219
220         public void setSourcePathResources(Map<String,File> sourcePathResources) {
221                 this.sourcePathResources = sourcePathResources;
222                 this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED;
223         }
224
225         public void setOutputLocationManager(IOutputLocationManager manager) {
226                 this.outputLocationManager = manager;
227         }
228
229         public void setClasspath(String path) {
230                 this.classPath = path;
231                 this.changed |= ICompilerConfiguration.CLASSPATH_CHANGED;
232         }
233
234         public int getConfigurationChanges() {
235                 return changed;
236                 // return EVERYTHING;
237         }
238
239         public void configurationRead() {
240                 changed = NO_CHANGES;
241                 modifiedFiles = null;
242                 modifiedDirs = null;
243         }
244
245         public List<String> getClasspathElementsWithModifiedContents() {
246                 return modifiedDirs;
247         }
248
249         public void setProjectEncoding(String encoding) {
250                 this.encoding = encoding;
251         }
252
253         public String getProjectEncoding() {
254                 return this.encoding;
255         }
256
257         public String getProcessor() {
258                 return this.processor;
259         }
260
261         public String getProcessorPath() {
262                 return this.processorPath;
263         }
264
265         @Override
266         public String getModulepath() {
267                 return null;
268         }
269
270         @Override
271         public String getModuleSourcepath() {
272                 return null;
273         }
274
275 }