]> source.dussan.org Git - aspectj.git/commitdiff
102733: broken code support, wooo
authoraclement <aclement>
Fri, 13 Jun 2008 23:23:23 +0000 (23:23 +0000)
committeraclement <aclement>
Fri, 13 Jun 2008 23:23:23 +0000 (23:23 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/ProceedOnErrorTestCase.java

index 13488e22487a8a4f53841bd34e7adc1569abb2d4..368b84ae356e799dcd4f960b193a68a3226f080e 100644 (file)
@@ -103,6 +103,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
     // If runtime version check fails, warn or fail? (unset?)
     static final boolean FAIL_IF_RUNTIME_NOT_FOUND = false;
     
+    // support for producing .class files containing errors and maintaining 'state' even when the
+    // project is broken (meaning all builds after the first are incremental)
+    public static boolean continueWhenErrors = true;
+    
     private static final FileFilter binarySourceFilter = 
                new FileFilter() {
                        public boolean accept(File f) {
@@ -186,7 +190,6 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
         throws IOException, AbortException {
         return doBuild(buildConfig, baseHandler, false);
     }
-    
 
     /** @throws AbortException if check for runtime fails */
     protected boolean doBuild(
@@ -265,10 +268,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                 binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true);
                 performCompilation(buildConfig.getFiles());
                 state.clearBinarySourceFiles(); // we don't want these hanging around...
-                if (handler.hasErrors()) {
+                if (!continueWhenErrors && handler.hasErrors()) {
                        CompilationAndWeavingContext.leavingPhase(ct);
-                       if (AsmManager.isReporting())
-                                   AsmManager.getDefault().reportModelInfo("After a failed batch build");
+                       if (AsmManager.isReporting())
+                                   AsmManager.getDefault().reportModelInfo("After a batch build");
                     return false;
                 }
 
@@ -293,7 +296,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                     // System.err.println("XXXX inc: " + files);
                
                     performCompilation(files);
-                    if (handler.hasErrors() || (progressListener!=null && progressListener.isCancelledRequested())) {
+                    if ((!continueWhenErrors && handler.hasErrors()) || (progressListener!=null && progressListener.isCancelledRequested())) {
                         CompilationAndWeavingContext.leavingPhase(ct);
                         return false;
                     } 
@@ -1027,7 +1030,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                        public void acceptResult(CompilationResult unitResult) {
                                // end of compile, must now write the results to the output destination
                                // this is either a jar file or a file in a directory
-                               if (!(unitResult.hasErrors() && !proceedOnError())) {                   
+                               if (!((unitResult.hasErrors() && !continueWhenErrors) && !proceedOnError())) {                  
                                        Collection classFiles = unitResult.compiledTypes.values();
                                        boolean shouldAddAspectName = (buildConfig.getOutxmlName() != null);
                                        for (Iterator iter = classFiles.iterator(); iter.hasNext();) {
index 570adf7aa20fbde06c3976e13a43feb4a2f66a21..4caa987bdca3d68a8c3bd719b5217a5b17d858fa 100644 (file)
@@ -16,6 +16,8 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Date;
 
+import org.aspectj.ajdt.internal.core.builder.AjBuildManager;
+
 
 public class ProceedOnErrorTestCase extends CommandTestCase {
 
@@ -29,17 +31,22 @@ public class ProceedOnErrorTestCase extends CommandTestCase {
         * C2.java.
         */
        public void testNoProceedOnError() throws IOException {
-               checkCompile("src1/C1.java", NO_ERRORS);
-           File f =new File(getSandboxName(),"C.class");
-           long oldmodtime = f.lastModified();
-           pause(2);
-               checkCompile("src1/C2.java", new int[]{1});
-           f =new File(getSandboxName(),"C.class");
-           long newmodtime = f.lastModified();
-        // Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
-           assertTrue("The .class file should not have been modified as '-proceedOnError' was not supplied (old="+
-                          new Date(oldmodtime).toString()+")(new="+new Date(newmodtime).toString()+")",
-                          oldmodtime==newmodtime);
+               try {
+                       AjBuildManager.continueWhenErrors=false;
+                       checkCompile("src1/C1.java", NO_ERRORS);
+                   File f =new File(getSandboxName(),"C.class");
+                   long oldmodtime = f.lastModified();
+                   pause(2);
+                       checkCompile("src1/C2.java", new int[]{1});
+                   f =new File(getSandboxName(),"C.class");
+                   long newmodtime = f.lastModified();
+               // Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
+                   assertTrue("The .class file should not have been modified as '-proceedOnError' was not supplied (old="+
+                                  new Date(oldmodtime).toString()+")(new="+new Date(newmodtime).toString()+")",
+                                  oldmodtime==newmodtime);
+               } finally {
+                       AjBuildManager.continueWhenErrors=true;
+               }
        }
 
        public void testProceedOnError() throws IOException {