*
* <p><u>Warnings</u>:
* <ol>
+ * <li>cleaning will not work if no destination directory
+ * is specified in the javac task
+ * (because we don't know where to put the tag file).</li>
* <li>cleaning will makes stepwise build processes fail
* if they depend on the results of the prior compilation being
* in the same directory, since this deletes <strong>all</strong>
* .class files.</li>
- * <li>If no files are out of date, then the adapter is never called
+ * <li>If no files are out of date, then the adapter is <b>never</b> called
* and thus cannot gain control to clean out the destination dir.
* </li>
* <p>
*
- * @author Wes Isberg <a href="mailto:isberg@aspectj.org">isberg@aspectj.org</a>
+ * @author Wes Isberg
* @since AspectJ 1.1, Ant 1.5.1
*/
public class Ajc11CompilerAdapter implements CompilerAdapter {
} else {
try {
AjcTask ajc = new AjcTask();
- String err = AjcTask.setupAjc(ajc, javac, getDestDir());
+ String err = ajc.setupAjc(javac);
if (null != err) {
throw new BuildException(err, javac.getLocation());
}
}
}
- protected File getDestDir() {
+ /**
+ * Get javac dest dir.
+ * @param client the String label for the client seeking the directory
+ * (only used in throwing BuildException)
+ * @return File dest dir
+ * @throws BuildException if not specified and required
+ */
+ protected File getDestDir(String client) {
checkJavac();
File destDir = javac.getDestdir();
if (null == destDir) {
- destDir = new File(".");
+ throw new BuildException("require destDir for " + client);
}
return destDir;
}
protected File getTagFile() {
- return new File(getDestDir(), "Ajc11CompilerAdapter.tag");
+ return new File(getDestDir("getting tag file directory"),
+ "Ajc11CompilerAdapter.tag");
}
/**
String cleanDirs = javac.getProject().getProperty(CLEAN);
if (null == cleanDirs) {
return false;
- }
+ }
+ File destDir = getDestDir("recursing to clean");
File tagFile = getTagFile();
if (tagFile.exists()) {
return false;
}
try {
- File destDir = getDestDir();
javac.log(CLEAN + " cleaning .class files from " + destDir,
Project.MSG_VERBOSE);
FileUtil.deleteContents(destDir, FileUtil.DIRS_AND_WRITABLE_CLASSES, true);
/**
* This runs the AspectJ 1.1 compiler,
* supporting all the command-line options.
- * It can also complete the output in
- * the destination directory or output jar
- * by copying non-.class files from all input jars
- * or copying resources from source root directories.
- * When copying anything to the output jar,
- * this will pass the AspectJ
- * compiler a path to a different temporary output jar file,
- * the contents of which will be copied along with any
- * resources to the actual output jar.
+ * In 1.1.1, ajc started copying resources from the
+ * source directory as javac does, but users might
+ * want to copy additional resources using
+ * sourceRootCopyFilter.
* When not forking, things will be copied as needed
* for each iterative compile,
* but when forking things are only copied at the
* @param destDir the File class destination directory (may be null)
* @return null if no error, or String error otherwise
*/
- public static String setupAjc(AjcTask ajc, Javac javac, File destDir) {
- if (null == ajc) {
- return "null ajc";
- } else if (null == javac) {
+ public String setupAjc(Javac javac) {
+ if (null == javac) {
return "null javac";
- } else if (null == destDir) {
- destDir = javac.getDestdir();
}
+ AjcTask ajc = this;
// no null checks b/c AjcTask handles null input gracefully
ajc.setProject(javac.getProject());
ajc.setLocation(javac.getLocation());
ajc.setVerbose(javac.getVerbose());
ajc.setTarget(javac.getTarget());
ajc.setSource(javac.getSource());
- ajc.setEncoding(javac.getEncoding());
- if (DEFAULT_DESTDIR != destDir) {
- ajc.setDestdir(destDir);
+ ajc.setEncoding(javac.getEncoding());
+ File javacDestDir = javac.getDestdir();
+ if (null != javacDestDir) {
+ ajc.setDestdir(javacDestDir);
}
ajc.setBootclasspath(javac.getBootclasspath());
ajc.setExtdirs(javac.getExtdirs());
// ignore srcDir -- all files picked up in recalculated file list
// ajc.setSrcDir(javac.getSrcdir());
ajc.addFiles(javac.getFileList());
- // mimic javac's behavior in copying resources,
- ajc.setSourceRootCopyFilter("**/CVS/*,**/*.java,**/*.aj");
// arguments can override the filter, add to paths, override options
ajc.readArguments(javac.getCurrentCompilerArgs());
* @throw BuildException if options conflict
*/
protected void verifyOptions() {
+ // log warnings - should be able to disable entirely,
+ // after they verify that this is indeed always working
+ if (null != sourceRootCopyFilter) {
+ log("sourceRootCopyFilter not required in 1.1.1", Project.MSG_WARN);
+ }
+ if (copyInjars) {
+ log("copyInjars not required in 1.1.1.\n", Project.MSG_WARN);
+ }
+
+ // throw BuildException for conflicting options
StringBuffer sb = new StringBuffer();
if (fork && isInIncrementalMode() && !isInIncrementalFileMode()) {
sb.append("can fork incremental only using tag file.\n");