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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  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. @SuppressWarnings({ "rawtypes", "unchecked" })
  463. void join(Collection local, Collection global) {
  464. for (Object next : global) {
  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.contains("=")) {
  501. this.lintMode = AJLINT_DEFAULT;
  502. lintOptionsMap = new HashMap<>();
  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<>();
  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<>();
  781. if (
  782. Arrays.stream(buildArgParser.getCheckedClasspaths())
  783. .anyMatch(cp -> cp instanceof ClasspathJep247)
  784. ) {
  785. allPaths.addAll(
  786. Arrays.stream(buildArgParser.getCheckedClasspaths())
  787. .filter(cp -> cp instanceof ClasspathJep247)
  788. .collect(Collectors.toList())
  789. );
  790. }
  791. else
  792. allPaths.addAll(processStringPath(bootclasspath, encoding));
  793. allPaths.addAll(processFilePath(inJars, encoding));
  794. allPaths.addAll(processFilePath(inPath, encoding));
  795. allPaths.addAll(processFilePath(aspectpath, encoding));
  796. if (modulepathClasspathEntries != null) {
  797. allPaths.addAll(modulepathClasspathEntries);
  798. }
  799. if (modulesourcepathClasspathEntries != null) {
  800. allPaths.addAll(modulesourcepathClasspathEntries);
  801. }
  802. // The classpath is done after modules to give precedence to modules that share the
  803. // same paths as classpath elements (the upcoming normalize will remove later dups)
  804. allPaths.addAll(processStringPath(classpath, encoding));
  805. allPaths.removeIf(Objects::isNull);
  806. allPaths = FileSystem.ClasspathNormalizer.normalize(allPaths);
  807. this.checkedClasspaths = new FileSystem.Classpath[allPaths.size()];
  808. allPaths.toArray(this.checkedClasspaths);
  809. for (Classpath checkedClasspath : checkedClasspaths) {
  810. if (checkedClasspath == null) {
  811. throw new IllegalStateException();
  812. }
  813. }
  814. }
  815. }