* <ul>
* <li>New list entries are added if not duplicates in,
* for classpath, aspectpath, injars, inpath and sourceroots</li>
- * <li>New bootclasspath entries are ignored XXX</li>
* <li>Set only one new entry for output dir or output jar
* only if there is no output dir/jar entry in the config</li>
* </ul>
*/
private void configureProjectOptions( AjBuildConfig config, ProjectPropertiesAdapter properties ) {
// XXX no error handling in copying project properties
- String propcp = properties.getClasspath(); // XXX omitting bootclasspath...
+ // Handle regular classpath
+ String propcp = properties.getClasspath();
if (!LangUtil.isEmpty(propcp)) {
StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator);
List configClasspath = config.getClasspath();
Ajde.getDefault().logEvent("building with classpath: " + both);
}
}
-
+
+ // Handle boot classpath
+ propcp = properties.getBootClasspath();
+ if (!LangUtil.isEmpty(propcp)) {
+ StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator);
+ List configClasspath = config.getBootclasspath();
+ ArrayList toAdd = new ArrayList();
+ while (st.hasMoreTokens()) {
+ String entry = st.nextToken();
+ if (!configClasspath.contains(entry)) {
+ toAdd.add(entry);
+ }
+ }
+ if (0 < toAdd.size()) {
+ ArrayList both = new ArrayList(configClasspath.size() + toAdd.size());
+ both.addAll(configClasspath);
+ both.addAll(toAdd);
+ config.setBootclasspath(both);
+ Ajde.getDefault().logEvent("building with boot classpath: " + both);
+ }
+ }
+
+
+
// set outputdir and outputjar only if both not set
if ((null == config.getOutputDir() && (null == config.getOutputJar()))) {
String outPath = properties.getOutputPath();
if (setClasspath) {
buildConfig.setClasspath(getClasspath(parser));
+ buildConfig.setBootclasspath(getBootclasspath(parser));
}
if (incrementalMode
}
+ public List getBootclasspath(AjcConfigParser parser) {
+ List ret = new ArrayList();
+
+ if (parser.bootclasspath == null) {
+ addClasspath(System.getProperty("sun.boot.class.path", ""), ret);
+ } else {
+ addClasspath(parser.bootclasspath, ret);
+ }
+ return ret;
+ }
/**
* If the classpath is not set, we use the environment's java.class.path, but remove
* the aspectjtools.jar entry from that list in order to prevent wierd bootstrap issues
public List getClasspath(AjcConfigParser parser) {
List ret = new ArrayList();
- if (parser.bootclasspath == null) {
- addClasspath(System.getProperty("sun.boot.class.path", ""), ret);
- } else {
- addClasspath(parser.bootclasspath, ret);
- }
+// if (parser.bootclasspath == null) {
+// addClasspath(System.getProperty("sun.boot.class.path", ""), ret);
+// } else {
+// addClasspath(parser.bootclasspath, ret);
+// }
String extdirs = parser.extdirs;
if (extdirs == null) {
* All configuration information needed to run the AspectJ compiler.
* Compiler options (as opposed to path information) are held in an AjCompilerOptions instance
*/
-public class AjBuildConfig { // XXX needs bootclasspath?
+public class AjBuildConfig {
private boolean shouldProceed = true;
private Map/*String->File*/ sourcePathResources = new HashMap();
private List/*File*/ aspectpath = new ArrayList();
private List/*String*/ classpath = new ArrayList();
+ private List/*String*/ bootclasspath = new ArrayList();
private File configFile;
private String lintMode = AJLINT_DEFAULT;
}
/**
- * This includes all entries from -bootclasspath, -extdirs, -classpath,
+ * This does not include -bootclasspath but includes -extdirs and -classpath
*/
public List getClasspath() { // XXX setters don't respect javadoc contract...
return classpath;
public void setClasspath(List classpath) {
this.classpath = classpath;
}
+
+ public List getBootclasspath() {
+ return bootclasspath;
+ }
+
+ public void setBootclasspath(List bootclasspath) {
+ this.bootclasspath = bootclasspath;
+ }
public File getOutputJar() {
return outputJar;
}
/**
- * @return List (String) classpath of injars, inpath, aspectpath
- * entries, specified classpath (bootclasspath, extdirs, and
- * classpath), and output dir or jar
+ * @return List (String) classpath of bootclasspath, injars, inpath, aspectpath
+ * entries, specified classpath (extdirs, and classpath), and output dir or jar
*/
public List getFullClasspath() {
List full = new ArrayList();
+ full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath?
for (Iterator i = inJars.iterator(); i.hasNext(); ) {
full.add(((File)i.next()).getAbsolutePath());
}
full.add(((File)i.next()).getAbsolutePath());
}
for (Iterator i = aspectpath.iterator(); i.hasNext(); ) {
- full.add(((File)i.next()).getAbsolutePath());
+ full.add(((File)i.next()).getAbsolutePath());
}
full.addAll(getClasspath());
// if (null != outputDir) {
/** init only on initial batch compile? no file-specific options */
private void initBcelWorld(IMessageHandler handler) throws IOException {
- bcelWorld = new BcelWorld(buildConfig.getClasspath(), handler, null);
+ List cp = buildConfig.getBootclasspath();
+ cp.addAll(buildConfig.getClasspath());
+ bcelWorld = new BcelWorld(cp, handler, null);
bcelWorld.setXnoInline(buildConfig.isXnoInline());
bcelWorld.setXlazyTjp(buildConfig.isXlazyTjp());
bcelWeaver = new BcelWeaver(bcelWorld);
}
String makeClasspathString() {
- if (buildConfig == null || buildConfig.getClasspath() == null) return "";
+ if (buildConfig == null || buildConfig.getFullClasspath() == null) return "";
StringBuffer buf = new StringBuffer();
boolean first = true;
- for (Iterator it = buildConfig.getClasspath().iterator(); it.hasNext(); ) {
+ for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext(); ) {
if (first) { first = false; }
else { buf.append(File.pathSeparator); }
buf.append(it.next().toString());
return null;
}
- if (buildConfig == null || buildConfig.getClasspath() == null) return "no classpath specified";
- for (Iterator it = buildConfig.getClasspath().iterator(); it.hasNext(); ) {
+ if (buildConfig == null || buildConfig.getFullClasspath() == null) return "no classpath specified";
+ for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext(); ) {
File p = new File( (String)it.next() );
if (p.isFile() && p.getName().equals("aspectjrt.jar")) {
public void testPathResolutionFromConfigArgs() {
String FILE_PATH = "@" + TEST_DIR + "configWithClasspathExtdirsBootCPArgs.lst";
AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH }, messageWriter);
- List classpath = config.getClasspath();
+ List classpath = config.getFullClasspath();
// should have three entries, resolved relative to location of .lst file
assertEquals("Three entries in classpath",3,classpath.size());
Iterator cpIter = classpath.iterator();
AjBuildConfig config = genBuildConfig(new String[] {
"-bootclasspath", PATH },
messageWriter);
- assertTrue("Should find '" + PATH + "' contained in the first entry of '" + config.getClasspath().toString(),
- ((String)config.getClasspath().get(0)).indexOf(PATH) != -1);
+ assertTrue("Should find '" + PATH + "' contained in the first entry of '" + config.getBootclasspath().toString(),
+ ((String)config.getBootclasspath().get(0)).indexOf(PATH) != -1);
config = genBuildConfig(new String[] {
},
messageWriter);
- assertTrue(config.getClasspath().toString(), !config.getClasspath().get(0).equals(PATH));
+ assertTrue(config.getBootclasspath().toString(), !config.getBootclasspath().get(0).equals(PATH));
}
public void testOutputJar() throws InvalidInputException {