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

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