From: wisberg Date: Thu, 28 Aug 2003 19:22:31 +0000 (+0000) Subject: updated fix for 40807 - compiler adapter was supplying destDir when not specified X-Git-Tag: V1_1_1~42 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d8b86743663c19fd545d8dea89290dccda7a5ed1;p=aspectj.git updated fix for 40807 - compiler adapter was supplying destDir when not specified Also adding warning for resource-copying (36071; copyInJars, sourceRootCopyFilter) I would like to disable entirely, but don't see and haven't gotten confirmation of behavior from last week's telephone call. --- diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java index 4e23c962b..77f0afced 100644 --- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java +++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapter.java @@ -40,16 +40,19 @@ import java.io.IOException; * *

Warnings: *

    + *
  1. 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).
  2. *
  3. 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 all * .class files.
  4. - *
  5. If no files are out of date, then the adapter is never called + *
  6. If no files are out of date, then the adapter is never called * and thus cannot gain control to clean out the destination dir. *
  7. *

    * - * @author Wes Isberg isberg@aspectj.org + * @author Wes Isberg * @since AspectJ 1.1, Ant 1.5.1 */ public class Ajc11CompilerAdapter implements CompilerAdapter { @@ -74,7 +77,7 @@ 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()); } @@ -93,17 +96,25 @@ public class Ajc11CompilerAdapter implements CompilerAdapter { } } - 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"); } /** @@ -123,13 +134,13 @@ public class Ajc11CompilerAdapter implements CompilerAdapter { 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); diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java index d1b6d4d5f..e444fdb31 100644 --- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -30,15 +30,10 @@ import org.aspectj.util.*; /** * 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 @@ -109,14 +104,11 @@ public class AjcTask extends MatchingTask { * @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()); @@ -135,9 +127,10 @@ public class AjcTask extends MatchingTask { 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()); @@ -145,8 +138,6 @@ public class AjcTask extends MatchingTask { // 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()); @@ -989,6 +980,16 @@ public class AjcTask extends MatchingTask { * @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");