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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  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<>();
  51. private List<File> changedFiles;
  52. private List<File> files = new ArrayList<>();
  53. private List<File> xmlfiles = new ArrayList<>();
  54. private String processor;
  55. private String processorPath;
  56. private List<BinarySourceFile> binaryFiles = new ArrayList<>(); // .class files in indirs...
  57. private List<File> inJars = new ArrayList<>();
  58. private List<File> inPath = new ArrayList<>();
  59. private Map<String, File> sourcePathResources = new HashMap<>();
  60. private List<File> aspectpath = new ArrayList<>();
  61. private List<String> classpath = new ArrayList<>();
  62. private List<String> modulepath = new ArrayList<>();
  63. // Expensive to compute (searching modules, parsing module-info)
  64. private Collection<Classpath> modulepathClasspathEntries = null;
  65. private List<String> modulesourcepath = new ArrayList<>();
  66. // Expensive to compute (searching modules, parsing module-info)
  67. private Collection<Classpath> modulesourcepathClasspathEntries = null;
  68. private Classpath[] checkedClasspaths = null;
  69. private List<String> bootclasspath = new ArrayList<>();
  70. private List<String> cpElementsWithModifiedContents = new ArrayList<>();
  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<>();
  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<>();
  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<>();
  266. FileFilter filter = new FileFilter() {
  267. @Override
  268. public boolean accept(File pathname) {
  269. return pathname.getPath().endsWith(".class");
  270. }
  271. };
  272. for (File inpathElement : inPath) {
  273. if (inpathElement.isDirectory()) {
  274. File[] files = FileUtil.listFiles(inpathElement, filter);
  275. for (File file : files) {
  276. binaryFiles.add(new BinarySourceFile(inpathElement, file));
  277. }
  278. }
  279. }
  280. }
  281. public void setInPath(List<File> dirsOrJars) {
  282. inPath = dirsOrJars;
  283. checkedClasspaths = null;
  284. processInPath();
  285. }
  286. public List<File> getSourceRoots() {
  287. return sourceRoots;
  288. }
  289. public void setSourceRoots(List<File> sourceRootDir) {
  290. this.sourceRoots = sourceRootDir;
  291. }
  292. public File getConfigFile() {
  293. return configFile;
  294. }
  295. public void setConfigFile(File configFile) {
  296. this.configFile = configFile;
  297. }
  298. public void setIncrementalMode(boolean incrementalMode) {
  299. this.incrementalMode = incrementalMode;
  300. }
  301. public boolean isIncrementalMode() {
  302. return incrementalMode;
  303. }
  304. public void setIncrementalFile(File incrementalFile) {
  305. this.incrementalFile = incrementalFile;
  306. }
  307. public boolean isIncrementalFileMode() {
  308. return (null != incrementalFile);
  309. }
  310. /**
  311. * @return List (String) classpath of bootclasspath, injars, inpath, aspectpath entries, specified classpath (extdirs, and
  312. * classpath), and output dir or jar
  313. */
  314. public List<String> getFullClasspath() {
  315. List<String> full = new ArrayList<>(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath?
  316. for (File file: inJars) {
  317. full.add(file.getAbsolutePath());
  318. }
  319. for (File file: inPath) {
  320. full.add(file.getAbsolutePath());
  321. }
  322. for (File file: aspectpath) {
  323. full.add(file.getAbsolutePath());
  324. }
  325. full.addAll(getClasspath());
  326. // full.addAll(getModulepath());
  327. // full.addAll(getModulesourcepath());
  328. // if (null != outputDir) {
  329. // full.add(outputDir.getAbsolutePath());
  330. // } else if (null != outputJar) {
  331. // full.add(outputJar.getAbsolutePath());
  332. // }
  333. return full;
  334. }
  335. public File getLintSpecFile() {
  336. return lintSpecFile;
  337. }
  338. public void setLintSpecFile(File lintSpecFile) {
  339. this.lintSpecFile = lintSpecFile;
  340. }
  341. public List<File> getAspectpath() {
  342. return Collections.unmodifiableList(aspectpath);
  343. }
  344. public void setAspectpath(List<File> aspectpath) {
  345. this.aspectpath = aspectpath;
  346. checkedClasspaths = null;
  347. }
  348. public void addToAspectpath(File file) {
  349. this.aspectpath.add(file);
  350. checkedClasspaths = null;
  351. }
  352. public void addToInjars(File file) {
  353. this.inJars.add(file);
  354. checkedClasspaths = null;
  355. }
  356. /** @return true if any config file, sourceroots, sourcefiles, injars or inpath */
  357. public boolean hasSources() {
  358. return ((null != configFile) || (0 < sourceRoots.size()) || (0 < files.size()) || (0 < inJars.size()) || (0 < inPath.size()));
  359. }
  360. // /** @return null if no errors, String errors otherwise */
  361. // public String configErrors() {
  362. // StringBuffer result = new StringBuffer();
  363. // // ok, permit both. sigh.
  364. // // if ((null != outputDir) && (null != outputJar)) {
  365. // // result.append("specified both outputDir and outputJar");
  366. // // }
  367. // // incremental => only sourceroots
  368. // //
  369. // return (0 == result.length() ? null : result.toString());
  370. // }
  371. /**
  372. * Install global values into local config unless values conflict:
  373. * <ul>
  374. * <li>Collections are unioned</li>
  375. * <li>values takes local value unless default and global set</li>
  376. * <li>this only sets one of outputDir and outputJar as needed</li>
  377. * </ul>
  378. * <p>This also configures super if javaOptions change.</p>
  379. *
  380. * @param global the AjBuildConfig to read globals from
  381. */
  382. public void installGlobals(AjBuildConfig global) { // XXX relies on default values
  383. // don't join the options - they already have defaults taken care of.
  384. // Map optionsMap = options.getMap();
  385. // join(optionsMap,global.getOptions().getMap());
  386. // options.set(optionsMap);
  387. options.defaultEncoding = global.options.defaultEncoding;// pr244321
  388. join(aspectpath, global.aspectpath);
  389. join(classpath, global.classpath);
  390. if (null == configFile) {
  391. configFile = global.configFile; // XXX correct?
  392. }
  393. if (!isEmacsSymMode() && global.isEmacsSymMode()) {
  394. setEmacsSymMode(true);
  395. }
  396. join(files, global.files);
  397. join(xmlfiles, global.xmlfiles);
  398. if (!isGenerateModelMode() && global.isGenerateModelMode()) {
  399. setGenerateModelMode(true);
  400. }
  401. if (null == incrementalFile) {
  402. incrementalFile = global.incrementalFile;
  403. }
  404. if (!incrementalMode && global.incrementalMode) {
  405. incrementalMode = true;
  406. }
  407. if (isCheckRuntimeVersion() && !global.isCheckRuntimeVersion()) {
  408. setCheckRuntimeVersion(false);
  409. }
  410. join(inJars, global.inJars);
  411. join(inPath, global.inPath);
  412. if ((null == lintMode) || (AJLINT_DEFAULT.equals(lintMode))) {
  413. setLintMode(global.lintMode);
  414. }
  415. if (null == lintSpecFile) {
  416. lintSpecFile = global.lintSpecFile;
  417. }
  418. if (!isTerminateAfterCompilation() && global.isTerminateAfterCompilation()) {
  419. setTerminateAfterCompilation(true);
  420. }
  421. if ((null == outputDir) && (null == outputJar)) {
  422. if (null != global.outputDir) {
  423. outputDir = global.outputDir;
  424. }
  425. if (null != global.outputJar) {
  426. outputJar = global.outputJar;
  427. }
  428. }
  429. join(sourceRoots, global.sourceRoots);
  430. if (!isXnoInline() && global.isXnoInline()) {
  431. setXnoInline(true);
  432. }
  433. if (!isXserializableAspects() && global.isXserializableAspects()) {
  434. setXserializableAspects(true);
  435. }
  436. if (!isXlazyTjp() && global.isXlazyTjp()) {
  437. setXlazyTjp(true);
  438. }
  439. if (!getProceedOnError() && global.getProceedOnError()) {
  440. setProceedOnError(true);
  441. }
  442. setTargetAspectjRuntimeLevel(global.getTargetAspectjRuntimeLevel());
  443. setXJoinpoints(global.getXJoinpoints());
  444. if (!isXHasMemberEnabled() && global.isXHasMemberEnabled()) {
  445. setXHasMemberSupport(true);
  446. }
  447. if (!isXNotReweavable() && global.isXNotReweavable()) {
  448. setXnotReweavable(true);
  449. }
  450. setOutxmlName(global.getOutxmlName());
  451. setXconfigurationInfo(global.getXconfigurationInfo());
  452. setAddSerialVerUID(global.isAddSerialVerUID());
  453. if (!isXmlConfigured() && global.isXmlConfigured()) {
  454. setXmlConfigured(global.isXmlConfigured());
  455. }
  456. setTiming(global.isTiming());
  457. setMakeReflectable(global.isMakeReflectable());
  458. }
  459. @SuppressWarnings({ "rawtypes", "unchecked" })
  460. void join(Collection local, Collection global) {
  461. for (Object next : global) {
  462. if (!local.contains(next)) {
  463. local.add(next);
  464. }
  465. }
  466. }
  467. public void setSourcePathResources(Map<String, File> map) {
  468. sourcePathResources = map;
  469. }
  470. /**
  471. * used to indicate whether to proceed after parsing config
  472. */
  473. public boolean shouldProceed() {
  474. return shouldProceed;
  475. }
  476. public void doNotProceed() {
  477. shouldProceed = false;
  478. }
  479. public String getLintMode() {
  480. return lintMode;
  481. }
  482. public Map<String,String> getLintOptionsMap() {
  483. return lintOptionsMap;
  484. }
  485. // options...
  486. public void setLintMode(String lintMode) {
  487. String lintValue = null;
  488. this.lintMode = lintMode;
  489. if (AJLINT_IGNORE.equals(lintMode)) {
  490. lintValue = AjCompilerOptions.IGNORE;
  491. } else if (AJLINT_WARN.equals(lintMode)) {
  492. lintValue = AjCompilerOptions.WARNING;
  493. } else if (AJLINT_ERROR.equals(lintMode)) {
  494. lintValue = AjCompilerOptions.ERROR;
  495. } else {
  496. // Possibly a name=value comma separated list of configurations
  497. if (lintMode.contains("=")) {
  498. this.lintMode = AJLINT_DEFAULT;
  499. lintOptionsMap = new HashMap<>();
  500. StringTokenizer tokenizer = new StringTokenizer(lintMode,",");
  501. while (tokenizer.hasMoreElements()) {
  502. String option = tokenizer.nextToken();
  503. int equals = option.indexOf("=");
  504. if (equals!=-1) {
  505. String key = option.substring(0,equals);
  506. String value = option.substring(equals+1);
  507. lintOptionsMap.put(key,value);
  508. }
  509. }
  510. }
  511. }
  512. if (lintValue != null || lintOptionsMap != null ) {
  513. Map<String, String> lintOptions = new HashMap<>();
  514. setOption(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName, lintValue, lintOptions);
  515. setOption(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName, lintValue, lintOptions);
  516. setOption(AjCompilerOptions.OPTION_ReportUnresolvableMember, lintValue, lintOptions);
  517. setOption(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver, lintValue, lintOptions);
  518. setOption(AjCompilerOptions.OPTION_ReportShadowNotInStructure, lintValue, lintOptions);
  519. setOption(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall, lintValue, lintOptions);
  520. setOption(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP, lintValue, lintOptions);
  521. setOption(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField, lintValue, lintOptions);
  522. setOption(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion, lintValue, lintOptions);
  523. options.set(lintOptions);
  524. }
  525. }
  526. private void setOption(String optionKey, String lintValue, Map<String,String> lintOptionsAccumulator) {
  527. if (lintOptionsMap!=null && lintOptionsMap.containsKey(optionKey)) {
  528. String v = lintOptionsMap.get(lintOptionsMap);
  529. if (AJLINT_IGNORE.equals(v)) {
  530. lintValue = AjCompilerOptions.IGNORE;
  531. } else if (AJLINT_WARN.equals(v)) {
  532. lintValue = AjCompilerOptions.WARNING;
  533. } else if (AJLINT_ERROR.equals(v)) {
  534. lintValue = AjCompilerOptions.ERROR;
  535. }
  536. }
  537. if (lintValue != null) {
  538. lintOptionsAccumulator.put(optionKey,lintValue);
  539. }
  540. }
  541. public boolean isTerminateAfterCompilation() {
  542. return options.terminateAfterCompilation;
  543. }
  544. public void setTerminateAfterCompilation(boolean b) {
  545. options.terminateAfterCompilation = b;
  546. }
  547. public boolean isXserializableAspects() {
  548. return options.xSerializableAspects;
  549. }
  550. public void setXserializableAspects(boolean xserializableAspects) {
  551. options.xSerializableAspects = xserializableAspects;
  552. }
  553. public void setXJoinpoints(String jps) {
  554. options.xOptionalJoinpoints = jps;
  555. }
  556. public String getXJoinpoints() {
  557. return options.xOptionalJoinpoints;
  558. }
  559. public boolean isXnoInline() {
  560. return options.xNoInline;
  561. }
  562. public void setXnoInline(boolean xnoInline) {
  563. options.xNoInline = xnoInline;
  564. }
  565. public boolean isXlazyTjp() {
  566. return options.xLazyThisJoinPoint;
  567. }
  568. public void setXlazyTjp(boolean b) {
  569. options.xLazyThisJoinPoint = b;
  570. }
  571. public void setXnotReweavable(boolean b) {
  572. options.xNotReweavable = b;
  573. }
  574. public void setXconfigurationInfo(String info) {
  575. options.xConfigurationInfo = info;
  576. }
  577. public String getXconfigurationInfo() {
  578. return options.xConfigurationInfo;
  579. }
  580. public void setXHasMemberSupport(boolean enabled) {
  581. options.xHasMember = enabled;
  582. }
  583. public boolean isXHasMemberEnabled() {
  584. return options.xHasMember;
  585. }
  586. public void setXdevPinpointMode(boolean enabled) {
  587. options.xdevPinpoint = enabled;
  588. }
  589. public boolean isXdevPinpoint() {
  590. return options.xdevPinpoint;
  591. }
  592. public void setAddSerialVerUID(boolean b) {
  593. options.addSerialVerUID = b;
  594. }
  595. public boolean isAddSerialVerUID() {
  596. return options.addSerialVerUID;
  597. }
  598. public void setXmlConfigured(boolean b) {
  599. options.xmlConfigured = b;
  600. }
  601. public void setMakeReflectable(boolean b) {
  602. options.makeReflectable = b;
  603. }
  604. public boolean isXmlConfigured() {
  605. return options.xmlConfigured;
  606. }
  607. public boolean isMakeReflectable() {
  608. return options.makeReflectable;
  609. }
  610. public boolean isXNotReweavable() {
  611. return options.xNotReweavable;
  612. }
  613. public boolean isGenerateJavadocsInModelMode() {
  614. return options.generateJavaDocsInModel;
  615. }
  616. public void setGenerateJavadocsInModelMode(boolean generateJavadocsInModelMode) {
  617. options.generateJavaDocsInModel = generateJavadocsInModelMode;
  618. }
  619. public boolean isGenerateCrossRefsMode() {
  620. return options.generateCrossRefs;
  621. }
  622. public void setGenerateCrossRefsMode(boolean on) {
  623. options.generateCrossRefs = on;
  624. }
  625. public boolean isCheckRuntimeVersion() {
  626. return options.checkRuntimeVersion;
  627. }
  628. public void setCheckRuntimeVersion(boolean on) {
  629. options.checkRuntimeVersion = on;
  630. }
  631. public boolean isEmacsSymMode() {
  632. return options.generateEmacsSymFiles;
  633. }
  634. public void setEmacsSymMode(boolean emacsSymMode) {
  635. options.generateEmacsSymFiles = emacsSymMode;
  636. }
  637. public boolean isGenerateModelMode() {
  638. return options.generateModel;
  639. }
  640. public void setGenerateModelMode(boolean structureModelMode) {
  641. options.generateModel = structureModelMode;
  642. }
  643. public boolean isNoAtAspectJAnnotationProcessing() {
  644. return options.noAtAspectJProcessing;
  645. }
  646. public void setNoAtAspectJAnnotationProcessing(boolean noProcess) {
  647. options.noAtAspectJProcessing = noProcess;
  648. }
  649. public void setShowWeavingInformation(boolean b) {
  650. options.showWeavingInformation = true;
  651. }
  652. public boolean getShowWeavingInformation() {
  653. return options.showWeavingInformation;
  654. }
  655. public void setProceedOnError(boolean b) {
  656. options.proceedOnError = b;
  657. }
  658. public boolean getProceedOnError() {
  659. return options.proceedOnError;
  660. }
  661. public void setBehaveInJava5Way(boolean b) {
  662. options.behaveInJava5Way = b;
  663. }
  664. public boolean getBehaveInJava5Way() {
  665. return options.behaveInJava5Way;
  666. }
  667. public void setTiming(boolean b) {
  668. options.timing = b;
  669. }
  670. public boolean isTiming() {
  671. return options.timing;
  672. }
  673. public void setTargetAspectjRuntimeLevel(String level) {
  674. options.targetAspectjRuntimeLevel = level;
  675. }
  676. public String getTargetAspectjRuntimeLevel() {
  677. return options.targetAspectjRuntimeLevel;
  678. }
  679. /**
  680. * Indicates what has changed in this configuration compared to the last time it was used, allowing the state management logic
  681. * to make intelligent optimizations and skip unnecessary work.
  682. *
  683. * @param changes set of bitflags, see {@link CompilerConfigurationChangeFlags} for flags
  684. */
  685. public void setChanged(int changes) {
  686. this.changes = changes;
  687. }
  688. /**
  689. * Return the bit flags indicating what has changed since the last time this config was used.
  690. *
  691. * @return the bitflags according too {@link CompilerConfigurationChangeFlags}
  692. */
  693. public int getChanged() {
  694. return this.changes;
  695. }
  696. public void setModifiedFiles(List<File> projectSourceFilesChanged) {
  697. this.changedFiles = projectSourceFilesChanged;
  698. }
  699. public List<File> getModifiedFiles() {
  700. return this.changedFiles;
  701. }
  702. public void setClasspathElementsWithModifiedContents(List<String> cpElementsWithModifiedContents) {
  703. this.cpElementsWithModifiedContents = cpElementsWithModifiedContents;
  704. }
  705. public List<String> getClasspathElementsWithModifiedContents() {
  706. return this.cpElementsWithModifiedContents;
  707. }
  708. public void setProjectEncoding(String projectEncoding) {
  709. options.defaultEncoding = projectEncoding;
  710. }
  711. public String getProjectEncoding() {
  712. return options.defaultEncoding;
  713. }
  714. public void setModuleDesc(IModule moduleDesc) {
  715. this.moduleDesc = moduleDesc;
  716. }
  717. public IModule getModuleDesc() {
  718. return moduleDesc;
  719. }
  720. public void addToInpath(Set<File> newInpathEntries) {
  721. if (newInpathEntries != null && newInpathEntries.size() != 0) {
  722. for (File newInpathEntry: newInpathEntries) {
  723. if (!inPath.contains(newInpathEntry)) {
  724. inPath.add(newInpathEntry);
  725. }
  726. }
  727. checkedClasspaths = null;
  728. }
  729. }
  730. public void addToInpath(File newInpathEntry) {
  731. // if (!inPath.contains(newInpathEntry)) {
  732. inPath.add(newInpathEntry);
  733. // }
  734. checkedClasspaths = null;
  735. }
  736. public void addToAspectpath(Set<File> newAspectpathEntries) {
  737. if (newAspectpathEntries != null && newAspectpathEntries.size() != 0) {
  738. for (File newAspectpathEntry: newAspectpathEntries) {
  739. if (!aspectpath.contains(newAspectpathEntry)) {
  740. aspectpath.add(newAspectpathEntry);
  741. }
  742. }
  743. checkedClasspaths = null;
  744. }
  745. }
  746. public void setModulepathClasspathEntries(ArrayList<Classpath> modulepathClasspathEntries) {
  747. this.modulepathClasspathEntries = modulepathClasspathEntries;
  748. }
  749. public void setModulesourcepathClasspathEntries(ArrayList<Classpath> modulesourcepathClasspathEntries) {
  750. this.modulesourcepathClasspathEntries = modulesourcepathClasspathEntries;
  751. }
  752. public File removeAspectPathEntry(int i) {
  753. checkedClasspaths = null;
  754. return aspectpath.remove(i);
  755. }
  756. public String removeClasspathEntry(int i) {
  757. checkedClasspaths = null;
  758. return classpath.remove(i);
  759. }
  760. public File removeInpathEntry(int i) {
  761. checkedClasspaths = null;
  762. return inPath.remove(i);
  763. }
  764. public File removeInjarsEntry(int i) {
  765. checkedClasspaths = null;
  766. return inJars.remove(0);
  767. }
  768. // This is similar to the calculation done in Main.setPaths() but it isn't as sophisticated
  769. // as that one (doesn't need to be) and it also considers the additional paths for an
  770. // AspectJ project (aspectpath/inpath/injars)
  771. private void computeCheckedClasspath() {
  772. // Follow what we do in getFullClasspath():
  773. // bootclasspath, injars, inpath, aspectpath, classpath, modulepath
  774. String encoding = getProjectEncoding();
  775. // What to do about bootclasspath on java 9?
  776. // ArrayList<Classpath> allPaths = handleBootclasspath(bootclasspaths, customEncoding);
  777. ArrayList<FileSystem.Classpath> allPaths = new ArrayList<>();
  778. allPaths.addAll(processStringPath(bootclasspath, encoding));
  779. allPaths.addAll(processFilePath(inJars, encoding));
  780. allPaths.addAll(processFilePath(inPath, encoding));
  781. allPaths.addAll(processFilePath(aspectpath, encoding));
  782. if (modulepathClasspathEntries != null) {
  783. allPaths.addAll(modulepathClasspathEntries);
  784. }
  785. if (modulesourcepathClasspathEntries != null) {
  786. allPaths.addAll(modulesourcepathClasspathEntries);
  787. }
  788. // The classpath is done after modules to give precedence to modules that share the
  789. // same paths as classpath elements (the upcoming normalize will remove later dups)
  790. allPaths.addAll(processStringPath(classpath, encoding));
  791. for (Iterator<FileSystem.Classpath> iter = allPaths.iterator();iter.hasNext();) {
  792. Classpath next = iter.next();
  793. if (next == null) {
  794. iter.remove();
  795. }
  796. }
  797. allPaths = FileSystem.ClasspathNormalizer.normalize(allPaths);
  798. this.checkedClasspaths = new FileSystem.Classpath[allPaths.size()];
  799. allPaths.toArray(this.checkedClasspaths);
  800. for (Classpath checkedClasspath : checkedClasspaths) {
  801. if (checkedClasspath == null) {
  802. throw new IllegalStateException();
  803. }
  804. }
  805. }
  806. }