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.

AjBuildConfig.java 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. /* *******************************************************************
  2. * Copyright (c) 2002 - 2018 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://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * Adrian Colyer added constructor to populate javaOptions with
  12. * default settings - 01.20.2003
  13. * Bugzilla #29768, 29769
  14. * Andy Clement
  15. * ******************************************************************/
  16. package org.aspectj.ajdt.internal.core.builder;
  17. import java.io.File;
  18. import java.io.FileFilter;
  19. import java.util.ArrayList;
  20. import java.util.Collection;
  21. import java.util.Collections;
  22. import java.util.HashMap;
  23. import java.util.Iterator;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.Set;
  27. import java.util.StringTokenizer;
  28. import org.aspectj.ajdt.ajc.BuildArgParser;
  29. import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
  30. import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathLocation;
  31. import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem;
  32. import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
  33. import org.aspectj.org.eclipse.jdt.internal.compiler.env.IModule;
  34. import org.aspectj.util.FileUtil;
  35. /**
  36. * All configuration information needed to run the AspectJ compiler. Compiler options (as opposed to path information) are held in
  37. * an AjCompilerOptions instance
  38. */
  39. public class AjBuildConfig implements CompilerConfigurationChangeFlags {
  40. public static final Classpath[] NO_CHECKED_CLASSPATHS = new Classpath[0];
  41. private boolean shouldProceed = true;
  42. public static final String AJLINT_IGNORE = "ignore";
  43. public static final String AJLINT_WARN = "warn";
  44. public static final String AJLINT_ERROR = "error";
  45. public static final String AJLINT_DEFAULT = "default";
  46. private File outputDir;
  47. private File outputJar;
  48. private String outxmlName;
  49. private CompilationResultDestinationManager compilationResultDestinationManager = null;
  50. private List<File> sourceRoots = new ArrayList<File>();
  51. private List<File> changedFiles;
  52. private List<File> files = new ArrayList<File>();
  53. private List<File> xmlfiles = new ArrayList<File>();
  54. private String processor;
  55. private String processorPath;
  56. private List<BinarySourceFile> binaryFiles = new ArrayList<BinarySourceFile>(); // .class files in indirs...
  57. private List<File> inJars = new ArrayList<File>();
  58. private List<File> inPath = new ArrayList<File>();
  59. private Map<String, File> sourcePathResources = new HashMap<String, File>();
  60. private List<File> aspectpath = new ArrayList<File>();
  61. private List<String> classpath = new ArrayList<String>();
  62. private List<String> modulepath = new ArrayList<String>();
  63. // Expensive to compute (searching modules, parsing module-info)
  64. private ArrayList<Classpath> modulepathClasspathEntries = null;
  65. private List<String> modulesourcepath = new ArrayList<String>();
  66. // Expensive to compute (searching modules, parsing module-info)
  67. private ArrayList<Classpath> modulesourcepathClasspathEntries = null;
  68. private Classpath[] checkedClasspaths = null;
  69. private List<String> bootclasspath = new ArrayList<String>();
  70. private List<String> cpElementsWithModifiedContents = new ArrayList<String>();
  71. private IModule moduleDesc;
  72. private File configFile;
  73. private String lintMode = AJLINT_DEFAULT;
  74. private Map<String,String> lintOptionsMap = null;
  75. private File lintSpecFile = null;
  76. private int changes = EVERYTHING; // bitflags, see CompilerConfigurationChangeFlags
  77. private final AjCompilerOptions options;
  78. private final BuildArgParser buildArgParser;
  79. // incremental variants handled by the compiler client, but parsed here
  80. private boolean incrementalMode;
  81. private File incrementalFile;
  82. @Override
  83. public String toString() {
  84. StringBuffer sb = new StringBuffer();
  85. sb.append("BuildConfig[" + (configFile == null ? "null" : configFile.getAbsoluteFile().toString()) + "] #Files="
  86. + files.size() + " AopXmls=#" + xmlfiles.size());
  87. return sb.toString();
  88. }
  89. public static class BinarySourceFile {
  90. public BinarySourceFile(File dir, File src) {
  91. this.fromInPathDirectory = dir;
  92. this.binSrc = src;
  93. }
  94. public File fromInPathDirectory;
  95. public File binSrc;
  96. @Override
  97. public boolean equals(Object obj) {
  98. if (obj != null && (obj instanceof BinarySourceFile)) {
  99. BinarySourceFile other = (BinarySourceFile) obj;
  100. return (binSrc.equals(other.binSrc));
  101. }
  102. return false;
  103. }
  104. @Override
  105. public int hashCode() {
  106. return binSrc != null ? binSrc.hashCode() : 0;
  107. }
  108. }
  109. /**
  110. * Intialises the javaOptions Map to hold the default JDT Compiler settings. Added by AMC 01.20.2003 in reponse to bug #29768
  111. * and enh. 29769. The settings here are duplicated from those set in org.eclipse.jdt.internal.compiler.batch.Main, but I've
  112. * elected to copy them rather than refactor the JDT class since this keeps integration with future JDT releases easier (?).
  113. */
  114. public AjBuildConfig(BuildArgParser buildArgParser) {
  115. this.buildArgParser = buildArgParser;
  116. options = new AjCompilerOptions();
  117. }
  118. public BuildArgParser getBuildArgParser() {
  119. return buildArgParser;
  120. }
  121. /**
  122. * returned files includes
  123. * <ul>
  124. * <li>files explicitly listed on command-line</li>
  125. * <li>files listed by reference in argument list files</li>
  126. * <li>files contained in sourceRootDir if that exists</li>
  127. * </ul>
  128. *
  129. * @return all source files that should be compiled.
  130. */
  131. public List<File> getFiles() {
  132. return files;
  133. }
  134. public List<File> getXmlFiles() {
  135. return xmlfiles;
  136. }
  137. public void setProcessor(String processor) {
  138. this.processor = processor;
  139. }
  140. /**
  141. * @return the list of processor classes to execute
  142. */
  143. public String getProcessor() {
  144. return this.processor;
  145. }
  146. public void setProcessorPath(String processorPath) {
  147. this.processorPath = processorPath;
  148. }
  149. /**
  150. * @return the processor path which can be searched for processors (via META-INF/services)
  151. */
  152. public String getProcessorPath() {
  153. return this.processorPath;
  154. }
  155. /**
  156. * returned files includes all .class files found in a directory on the inpath, but does not include .class files contained
  157. * within jars.
  158. */
  159. public List<BinarySourceFile> getBinaryFiles() {
  160. return binaryFiles;
  161. }
  162. public File getOutputDir() {
  163. return outputDir;
  164. }
  165. public CompilationResultDestinationManager getCompilationResultDestinationManager() {
  166. return this.compilationResultDestinationManager;
  167. }
  168. public void setCompilationResultDestinationManager(CompilationResultDestinationManager mgr) {
  169. this.compilationResultDestinationManager = mgr;
  170. }
  171. public void setFiles(List<File> files) {
  172. this.files = files;
  173. }
  174. public void setXmlFiles(List<File> xmlfiles) {
  175. this.xmlfiles = xmlfiles;
  176. }
  177. public void setOutputDir(File outputDir) {
  178. this.outputDir = outputDir;
  179. }
  180. public AjCompilerOptions getOptions() {
  181. return options;
  182. }
  183. /**
  184. * This does not include -bootclasspath but includes -extdirs and -classpath
  185. */
  186. public List<String> getClasspath() {
  187. return classpath;
  188. }
  189. public void setClasspath(List<String> classpath) {
  190. this.classpath = classpath;
  191. checkedClasspaths = null;
  192. }
  193. public List<String> getModulepath() {
  194. return modulepath;
  195. }
  196. public List<String> getModulesourcepath() {
  197. return modulesourcepath;
  198. }
  199. public void setModulepath(List<String> modulepath) {
  200. this.modulepath = modulepath;
  201. checkedClasspaths = null;
  202. }
  203. public void setModulesourcepath(List<String> modulesourcepath) {
  204. this.modulesourcepath = modulesourcepath;
  205. checkedClasspaths = null;
  206. }
  207. public void setCheckedClasspaths(Classpath[] checkedClasspaths) {
  208. this.checkedClasspaths = checkedClasspaths;
  209. checkedClasspaths = null;
  210. }
  211. private List<Classpath> processFilePath(List<File> path, java.lang.String encoding) {
  212. List<Classpath> entries = new ArrayList<Classpath>();
  213. for (File file: path) {
  214. entries.add(FileSystem.getClasspath(file.getAbsolutePath(), encoding, null, ClasspathLocation.BINARY, null));
  215. }
  216. return entries;
  217. }
  218. private List<Classpath> processStringPath(List<String> path, java.lang.String encoding) {
  219. List<Classpath> entries = new ArrayList<Classpath>();
  220. for (String file: path) {
  221. entries.add(FileSystem.getClasspath(file, encoding, null, ClasspathLocation.BINARY, null));
  222. }
  223. return entries;
  224. }
  225. public Classpath[] getCheckedClasspaths() {
  226. if (checkedClasspaths == null) {
  227. computeCheckedClasspath();
  228. }
  229. return checkedClasspaths;
  230. }
  231. public List<String> getBootclasspath() {
  232. return bootclasspath;
  233. }
  234. public void setBootclasspath(List<String> bootclasspath) {
  235. this.bootclasspath = bootclasspath;
  236. }
  237. public File getOutputJar() {
  238. return outputJar;
  239. }
  240. public String getOutxmlName() {
  241. return outxmlName;
  242. }
  243. public List<File> getInpath() {
  244. // Elements of the list are either archives (jars/zips) or directories
  245. return Collections.unmodifiableList(inPath);
  246. }
  247. public List<File> getInJars() {
  248. return inJars;
  249. }
  250. public Map<String, File> getSourcePathResources() {
  251. return sourcePathResources;
  252. }
  253. public void setOutputJar(File outputJar) {
  254. this.outputJar = outputJar;
  255. }
  256. public void setOutxmlName(String name) {
  257. this.outxmlName = name;
  258. }
  259. public void setInJars(List<File> sourceJars) {
  260. this.inJars = sourceJars;
  261. checkedClasspaths = null;
  262. }
  263. public void processInPath() {
  264. // remember all the class files in directories on the inpath
  265. binaryFiles = new ArrayList<BinarySourceFile>();
  266. FileFilter filter = new FileFilter() {
  267. @Override
  268. public boolean accept(File pathname) {
  269. return pathname.getPath().endsWith(".class");
  270. }
  271. };
  272. for (Iterator<File> iter = inPath.iterator(); iter.hasNext();) {
  273. File inpathElement = iter.next();
  274. if (inpathElement.isDirectory()) {
  275. File[] files = FileUtil.listFiles(inpathElement, filter);
  276. for (int i = 0; i < files.length; i++) {
  277. binaryFiles.add(new BinarySourceFile(inpathElement, files[i]));
  278. }
  279. }
  280. }
  281. }
  282. public void setInPath(List<File> dirsOrJars) {
  283. inPath = dirsOrJars;
  284. checkedClasspaths = null;
  285. processInPath();
  286. }
  287. public List<File> getSourceRoots() {
  288. return sourceRoots;
  289. }
  290. public void setSourceRoots(List<File> sourceRootDir) {
  291. this.sourceRoots = sourceRootDir;
  292. }
  293. public File getConfigFile() {
  294. return configFile;
  295. }
  296. public void setConfigFile(File configFile) {
  297. this.configFile = configFile;
  298. }
  299. public void setIncrementalMode(boolean incrementalMode) {
  300. this.incrementalMode = incrementalMode;
  301. }
  302. public boolean isIncrementalMode() {
  303. return incrementalMode;
  304. }
  305. public void setIncrementalFile(File incrementalFile) {
  306. this.incrementalFile = incrementalFile;
  307. }
  308. public boolean isIncrementalFileMode() {
  309. return (null != incrementalFile);
  310. }
  311. /**
  312. * @return List (String) classpath of bootclasspath, injars, inpath, aspectpath entries, specified classpath (extdirs, and
  313. * classpath), and output dir or jar
  314. */
  315. public List<String> getFullClasspath() {
  316. List<String> full = new ArrayList<String>();
  317. full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath?
  318. for (File file: inJars) {
  319. full.add(file.getAbsolutePath());
  320. }
  321. for (File file: inPath) {
  322. full.add(file.getAbsolutePath());
  323. }
  324. for (File file: aspectpath) {
  325. full.add(file.getAbsolutePath());
  326. }
  327. full.addAll(getClasspath());
  328. // full.addAll(getModulepath());
  329. // full.addAll(getModulesourcepath());
  330. // if (null != outputDir) {
  331. // full.add(outputDir.getAbsolutePath());
  332. // } else if (null != outputJar) {
  333. // full.add(outputJar.getAbsolutePath());
  334. // }
  335. return full;
  336. }
  337. public File getLintSpecFile() {
  338. return lintSpecFile;
  339. }
  340. public void setLintSpecFile(File lintSpecFile) {
  341. this.lintSpecFile = lintSpecFile;
  342. }
  343. public List<File> getAspectpath() {
  344. return Collections.unmodifiableList(aspectpath);
  345. }
  346. public void setAspectpath(List<File> aspectpath) {
  347. this.aspectpath = aspectpath;
  348. checkedClasspaths = null;
  349. }
  350. public void addToAspectpath(File file) {
  351. this.aspectpath.add(file);
  352. checkedClasspaths = null;
  353. }
  354. public void addToInjars(File file) {
  355. this.inJars.add(file);
  356. checkedClasspaths = null;
  357. }
  358. /** @return true if any config file, sourceroots, sourcefiles, injars or inpath */
  359. public boolean hasSources() {
  360. return ((null != configFile) || (0 < sourceRoots.size()) || (0 < files.size()) || (0 < inJars.size()) || (0 < inPath.size()));
  361. }
  362. // /** @return null if no errors, String errors otherwise */
  363. // public String configErrors() {
  364. // StringBuffer result = new StringBuffer();
  365. // // ok, permit both. sigh.
  366. // // if ((null != outputDir) && (null != outputJar)) {
  367. // // result.append("specified both outputDir and outputJar");
  368. // // }
  369. // // incremental => only sourceroots
  370. // //
  371. // return (0 == result.length() ? null : result.toString());
  372. // }
  373. /**
  374. * Install global values into local config unless values conflict:
  375. * <ul>
  376. * <li>Collections are unioned</li>
  377. * <li>values takes local value unless default and global set</li>
  378. * <li>this only sets one of outputDir and outputJar as needed</li>
  379. * <ul>
  380. * This also configures super if javaOptions change.
  381. *
  382. * @param global the AjBuildConfig to read globals from
  383. */
  384. public void installGlobals(AjBuildConfig global) { // XXX relies on default values
  385. // don't join the options - they already have defaults taken care of.
  386. // Map optionsMap = options.getMap();
  387. // join(optionsMap,global.getOptions().getMap());
  388. // options.set(optionsMap);
  389. options.defaultEncoding = global.options.defaultEncoding;// pr244321
  390. join(aspectpath, global.aspectpath);
  391. join(classpath, global.classpath);
  392. if (null == configFile) {
  393. configFile = global.configFile; // XXX correct?
  394. }
  395. if (!isEmacsSymMode() && global.isEmacsSymMode()) {
  396. setEmacsSymMode(true);
  397. }
  398. join(files, global.files);
  399. join(xmlfiles, global.xmlfiles);
  400. if (!isGenerateModelMode() && global.isGenerateModelMode()) {
  401. setGenerateModelMode(true);
  402. }
  403. if (null == incrementalFile) {
  404. incrementalFile = global.incrementalFile;
  405. }
  406. if (!incrementalMode && global.incrementalMode) {
  407. incrementalMode = true;
  408. }
  409. if (isCheckRuntimeVersion() && !global.isCheckRuntimeVersion()) {
  410. setCheckRuntimeVersion(false);
  411. }
  412. join(inJars, global.inJars);
  413. join(inPath, global.inPath);
  414. if ((null == lintMode) || (AJLINT_DEFAULT.equals(lintMode))) {
  415. setLintMode(global.lintMode);
  416. }
  417. if (null == lintSpecFile) {
  418. lintSpecFile = global.lintSpecFile;
  419. }
  420. if (!isTerminateAfterCompilation() && global.isTerminateAfterCompilation()) {
  421. setTerminateAfterCompilation(true);
  422. }
  423. if ((null == outputDir) && (null == outputJar)) {
  424. if (null != global.outputDir) {
  425. outputDir = global.outputDir;
  426. }
  427. if (null != global.outputJar) {
  428. outputJar = global.outputJar;
  429. }
  430. }
  431. join(sourceRoots, global.sourceRoots);
  432. if (!isXnoInline() && global.isXnoInline()) {
  433. setXnoInline(true);
  434. }
  435. if (!isXserializableAspects() && global.isXserializableAspects()) {
  436. setXserializableAspects(true);
  437. }
  438. if (!isXlazyTjp() && global.isXlazyTjp()) {
  439. setXlazyTjp(true);
  440. }
  441. if (!getProceedOnError() && global.getProceedOnError()) {
  442. setProceedOnError(true);
  443. }
  444. setTargetAspectjRuntimeLevel(global.getTargetAspectjRuntimeLevel());
  445. setXJoinpoints(global.getXJoinpoints());
  446. if (!isXHasMemberEnabled() && global.isXHasMemberEnabled()) {
  447. setXHasMemberSupport(true);
  448. }
  449. if (!isXNotReweavable() && global.isXNotReweavable()) {
  450. setXnotReweavable(true);
  451. }
  452. setOutxmlName(global.getOutxmlName());
  453. setXconfigurationInfo(global.getXconfigurationInfo());
  454. setAddSerialVerUID(global.isAddSerialVerUID());
  455. if (!isXmlConfigured() && global.isXmlConfigured()) {
  456. setXmlConfigured(global.isXmlConfigured());
  457. }
  458. setTiming(global.isTiming());
  459. setMakeReflectable(global.isMakeReflectable());
  460. }
  461. @SuppressWarnings({ "rawtypes", "unchecked" })
  462. void join(Collection local, Collection global) {
  463. for (Iterator iter = global.iterator(); iter.hasNext();) {
  464. Object next = iter.next();
  465. if (!local.contains(next)) {
  466. local.add(next);
  467. }
  468. }
  469. }
  470. public void setSourcePathResources(Map<String, File> map) {
  471. sourcePathResources = map;
  472. }
  473. /**
  474. * used to indicate whether to proceed after parsing config
  475. */
  476. public boolean shouldProceed() {
  477. return shouldProceed;
  478. }
  479. public void doNotProceed() {
  480. shouldProceed = false;
  481. }
  482. public String getLintMode() {
  483. return lintMode;
  484. }
  485. public Map<String,String> getLintOptionsMap() {
  486. return lintOptionsMap;
  487. }
  488. // options...
  489. public void setLintMode(String lintMode) {
  490. String lintValue = null;
  491. this.lintMode = lintMode;
  492. if (AJLINT_IGNORE.equals(lintMode)) {
  493. lintValue = AjCompilerOptions.IGNORE;
  494. } else if (AJLINT_WARN.equals(lintMode)) {
  495. lintValue = AjCompilerOptions.WARNING;
  496. } else if (AJLINT_ERROR.equals(lintMode)) {
  497. lintValue = AjCompilerOptions.ERROR;
  498. } else {
  499. // Possibly a name=value comma separated list of configurations
  500. if (lintMode.indexOf("=")!=-1) {
  501. this.lintMode = AJLINT_DEFAULT;
  502. lintOptionsMap = new HashMap<String,String>();
  503. StringTokenizer tokenizer = new StringTokenizer(lintMode,",");
  504. while (tokenizer.hasMoreElements()) {
  505. String option = tokenizer.nextToken();
  506. int equals = option.indexOf("=");
  507. if (equals!=-1) {
  508. String key = option.substring(0,equals);
  509. String value = option.substring(equals+1);
  510. lintOptionsMap.put(key,value);
  511. }
  512. }
  513. }
  514. }
  515. if (lintValue != null || lintOptionsMap != null ) {
  516. Map<String, String> lintOptions = new HashMap<String, String>();
  517. setOption(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName, lintValue, lintOptions);
  518. setOption(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName, lintValue, lintOptions);
  519. setOption(AjCompilerOptions.OPTION_ReportUnresolvableMember, lintValue, lintOptions);
  520. setOption(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver, lintValue, lintOptions);
  521. setOption(AjCompilerOptions.OPTION_ReportShadowNotInStructure, lintValue, lintOptions);
  522. setOption(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall, lintValue, lintOptions);
  523. setOption(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP, lintValue, lintOptions);
  524. setOption(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField, lintValue, lintOptions);
  525. setOption(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion, lintValue, lintOptions);
  526. options.set(lintOptions);
  527. }
  528. }
  529. private void setOption(String optionKey, String lintValue, Map<String,String> lintOptionsAccumulator) {
  530. if (lintOptionsMap!=null && lintOptionsMap.containsKey(optionKey)) {
  531. String v = lintOptionsMap.get(lintOptionsMap);
  532. if (AJLINT_IGNORE.equals(v)) {
  533. lintValue = AjCompilerOptions.IGNORE;
  534. } else if (AJLINT_WARN.equals(v)) {
  535. lintValue = AjCompilerOptions.WARNING;
  536. } else if (AJLINT_ERROR.equals(v)) {
  537. lintValue = AjCompilerOptions.ERROR;
  538. }
  539. }
  540. if (lintValue != null) {
  541. lintOptionsAccumulator.put(optionKey,lintValue);
  542. }
  543. }
  544. public boolean isTerminateAfterCompilation() {
  545. return options.terminateAfterCompilation;
  546. }
  547. public void setTerminateAfterCompilation(boolean b) {
  548. options.terminateAfterCompilation = b;
  549. }
  550. public boolean isXserializableAspects() {
  551. return options.xSerializableAspects;
  552. }
  553. public void setXserializableAspects(boolean xserializableAspects) {
  554. options.xSerializableAspects = xserializableAspects;
  555. }
  556. public void setXJoinpoints(String jps) {
  557. options.xOptionalJoinpoints = jps;
  558. }
  559. public String getXJoinpoints() {
  560. return options.xOptionalJoinpoints;
  561. }
  562. public boolean isXnoInline() {
  563. return options.xNoInline;
  564. }
  565. public void setXnoInline(boolean xnoInline) {
  566. options.xNoInline = xnoInline;
  567. }
  568. public boolean isXlazyTjp() {
  569. return options.xLazyThisJoinPoint;
  570. }
  571. public void setXlazyTjp(boolean b) {
  572. options.xLazyThisJoinPoint = b;
  573. }
  574. public void setXnotReweavable(boolean b) {
  575. options.xNotReweavable = b;
  576. }
  577. public void setXconfigurationInfo(String info) {
  578. options.xConfigurationInfo = info;
  579. }
  580. public String getXconfigurationInfo() {
  581. return options.xConfigurationInfo;
  582. }
  583. public void setXHasMemberSupport(boolean enabled) {
  584. options.xHasMember = enabled;
  585. }
  586. public boolean isXHasMemberEnabled() {
  587. return options.xHasMember;
  588. }
  589. public void setXdevPinpointMode(boolean enabled) {
  590. options.xdevPinpoint = enabled;
  591. }
  592. public boolean isXdevPinpoint() {
  593. return options.xdevPinpoint;
  594. }
  595. public void setAddSerialVerUID(boolean b) {
  596. options.addSerialVerUID = b;
  597. }
  598. public boolean isAddSerialVerUID() {
  599. return options.addSerialVerUID;
  600. }
  601. public void setXmlConfigured(boolean b) {
  602. options.xmlConfigured = b;
  603. }
  604. public void setMakeReflectable(boolean b) {
  605. options.makeReflectable = b;
  606. }
  607. public boolean isXmlConfigured() {
  608. return options.xmlConfigured;
  609. }
  610. public boolean isMakeReflectable() {
  611. return options.makeReflectable;
  612. }
  613. public boolean isXNotReweavable() {
  614. return options.xNotReweavable;
  615. }
  616. public boolean isGenerateJavadocsInModelMode() {
  617. return options.generateJavaDocsInModel;
  618. }
  619. public void setGenerateJavadocsInModelMode(boolean generateJavadocsInModelMode) {
  620. options.generateJavaDocsInModel = generateJavadocsInModelMode;
  621. }
  622. public boolean isGenerateCrossRefsMode() {
  623. return options.generateCrossRefs;
  624. }
  625. public void setGenerateCrossRefsMode(boolean on) {
  626. options.generateCrossRefs = on;
  627. }
  628. public boolean isCheckRuntimeVersion() {
  629. return options.checkRuntimeVersion;
  630. }
  631. public void setCheckRuntimeVersion(boolean on) {
  632. options.checkRuntimeVersion = on;
  633. }
  634. public boolean isEmacsSymMode() {
  635. return options.generateEmacsSymFiles;
  636. }
  637. public void setEmacsSymMode(boolean emacsSymMode) {
  638. options.generateEmacsSymFiles = emacsSymMode;
  639. }
  640. public boolean isGenerateModelMode() {
  641. return options.generateModel;
  642. }
  643. public void setGenerateModelMode(boolean structureModelMode) {
  644. options.generateModel = structureModelMode;
  645. }
  646. public boolean isNoAtAspectJAnnotationProcessing() {
  647. return options.noAtAspectJProcessing;
  648. }
  649. public void setNoAtAspectJAnnotationProcessing(boolean noProcess) {
  650. options.noAtAspectJProcessing = noProcess;
  651. }
  652. public void setShowWeavingInformation(boolean b) {
  653. options.showWeavingInformation = true;
  654. }
  655. public boolean getShowWeavingInformation() {
  656. return options.showWeavingInformation;
  657. }
  658. public void setProceedOnError(boolean b) {
  659. options.proceedOnError = b;
  660. }
  661. public boolean getProceedOnError() {
  662. return options.proceedOnError;
  663. }
  664. public void setBehaveInJava5Way(boolean b) {
  665. options.behaveInJava5Way = b;
  666. }
  667. public boolean getBehaveInJava5Way() {
  668. return options.behaveInJava5Way;
  669. }
  670. public void setTiming(boolean b) {
  671. options.timing = b;
  672. }
  673. public boolean isTiming() {
  674. return options.timing;
  675. }
  676. public void setTargetAspectjRuntimeLevel(String level) {
  677. options.targetAspectjRuntimeLevel = level;
  678. }
  679. public String getTargetAspectjRuntimeLevel() {
  680. return options.targetAspectjRuntimeLevel;
  681. }
  682. /**
  683. * Indicates what has changed in this configuration compared to the last time it was used, allowing the state management logic
  684. * to make intelligent optimizations and skip unnecessary work.
  685. *
  686. * @param changes set of bitflags, see {@link CompilerConfigurationChangeFlags} for flags
  687. */
  688. public void setChanged(int changes) {
  689. this.changes = changes;
  690. }
  691. /**
  692. * Return the bit flags indicating what has changed since the last time this config was used.
  693. *
  694. * @return the bitflags according too {@link CompilerConfigurationChangeFlags}
  695. */
  696. public int getChanged() {
  697. return this.changes;
  698. }
  699. public void setModifiedFiles(List<File> projectSourceFilesChanged) {
  700. this.changedFiles = projectSourceFilesChanged;
  701. }
  702. public List<File> getModifiedFiles() {
  703. return this.changedFiles;
  704. }
  705. public void setClasspathElementsWithModifiedContents(List<String> cpElementsWithModifiedContents) {
  706. this.cpElementsWithModifiedContents = cpElementsWithModifiedContents;
  707. }
  708. public List<String> getClasspathElementsWithModifiedContents() {
  709. return this.cpElementsWithModifiedContents;
  710. }
  711. public void setProjectEncoding(String projectEncoding) {
  712. options.defaultEncoding = projectEncoding;
  713. }
  714. public String getProjectEncoding() {
  715. return options.defaultEncoding;
  716. }
  717. public void setModuleDesc(IModule moduleDesc) {
  718. this.moduleDesc = moduleDesc;
  719. }
  720. public IModule getModuleDesc() {
  721. return moduleDesc;
  722. }
  723. public void addToInpath(Set<File> newInpathEntries) {
  724. if (newInpathEntries != null && newInpathEntries.size() != 0) {
  725. for (File newInpathEntry: newInpathEntries) {
  726. if (!inPath.contains(newInpathEntry)) {
  727. inPath.add(newInpathEntry);
  728. }
  729. }
  730. checkedClasspaths = null;
  731. }
  732. }
  733. public void addToInpath(File newInpathEntry) {
  734. // if (!inPath.contains(newInpathEntry)) {
  735. inPath.add(newInpathEntry);
  736. // }
  737. checkedClasspaths = null;
  738. }
  739. public void addToAspectpath(Set<File> newAspectpathEntries) {
  740. if (newAspectpathEntries != null && newAspectpathEntries.size() != 0) {
  741. for (File newAspectpathEntry: newAspectpathEntries) {
  742. if (!aspectpath.contains(newAspectpathEntry)) {
  743. aspectpath.add(newAspectpathEntry);
  744. }
  745. }
  746. checkedClasspaths = null;
  747. }
  748. }
  749. public void setModulepathClasspathEntries(ArrayList<Classpath> modulepathClasspathEntries) {
  750. this.modulepathClasspathEntries = modulepathClasspathEntries;
  751. }
  752. public void setModulesourcepathClasspathEntries(ArrayList<Classpath> modulesourcepathClasspathEntries) {
  753. this.modulesourcepathClasspathEntries = modulesourcepathClasspathEntries;
  754. }
  755. public File removeAspectPathEntry(int i) {
  756. checkedClasspaths = null;
  757. return aspectpath.remove(i);
  758. }
  759. public String removeClasspathEntry(int i) {
  760. checkedClasspaths = null;
  761. return classpath.remove(i);
  762. }
  763. public File removeInpathEntry(int i) {
  764. checkedClasspaths = null;
  765. return inPath.remove(i);
  766. }
  767. public File removeInjarsEntry(int i) {
  768. checkedClasspaths = null;
  769. return inJars.remove(0);
  770. }
  771. // This is similar to the calculation done in Main.setPaths() but it isn't as sophisticated
  772. // as that one (doesn't need to be) and it also considers the additional paths for an
  773. // AspectJ project (aspectpath/inpath/injars)
  774. private void computeCheckedClasspath() {
  775. // Follow what we do in getFullClasspath():
  776. // bootclasspath, injars, inpath, aspectpath, classpath, modulepath
  777. String encoding = getProjectEncoding();
  778. // What to do about bootclasspath on java 9?
  779. // ArrayList<Classpath> allPaths = handleBootclasspath(bootclasspaths, customEncoding);
  780. ArrayList<FileSystem.Classpath> allPaths = new ArrayList<FileSystem.Classpath>();
  781. allPaths.addAll(processStringPath(bootclasspath, encoding));
  782. allPaths.addAll(processFilePath(inJars, encoding));
  783. allPaths.addAll(processFilePath(inPath, encoding));
  784. allPaths.addAll(processFilePath(aspectpath, encoding));
  785. if (modulepathClasspathEntries != null) {
  786. allPaths.addAll(modulepathClasspathEntries);
  787. }
  788. if (modulesourcepathClasspathEntries != null) {
  789. allPaths.addAll(modulesourcepathClasspathEntries);
  790. }
  791. // The classpath is done after modules to give precedence to modules that share the
  792. // same paths as classpath elements (the upcoming normalize will remove later dups)
  793. allPaths.addAll(processStringPath(classpath, encoding));
  794. for (Iterator<FileSystem.Classpath> iter = allPaths.iterator();iter.hasNext();) {
  795. Classpath next = iter.next();
  796. if (next == null) {
  797. iter.remove();
  798. }
  799. }
  800. allPaths = FileSystem.ClasspathNormalizer.normalize(allPaths);
  801. this.checkedClasspaths = new FileSystem.Classpath[allPaths.size()];
  802. allPaths.toArray(this.checkedClasspaths);
  803. for (int i=0;i<checkedClasspaths.length;i++) {
  804. if (checkedClasspaths[i] == null) {
  805. throw new IllegalStateException();
  806. }
  807. }
  808. }
  809. }