]> source.dussan.org Git - aspectj.git/commitdiff
generalize report API to cover resources and outjar
authoraclement <aclement>
Mon, 23 Mar 2009 02:29:21 +0000 (02:29 +0000)
committeraclement <aclement>
Mon, 23 Mar 2009 02:29:21 +0000 (02:29 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java

index 3b10ab079aa18354d58434a722e69336d6c4b3da..cec06359e71cb63d3f0ec31cbff31f738a3d1309 100644 (file)
@@ -38,6 +38,7 @@ import java.util.zip.ZipEntry;
 
 import org.aspectj.ajdt.internal.compiler.AjCompilerAdapter;
 import org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter;
+import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
 import org.aspectj.ajdt.internal.compiler.IBinarySourceProvider;
 import org.aspectj.ajdt.internal.compiler.ICompilerAdapter;
 import org.aspectj.ajdt.internal.compiler.ICompilerAdapterFactory;
@@ -410,12 +411,20 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
                try {
                        if (zos != null) {
                                zos.close();
+                               if (buildConfig.getCompilationResultDestinationManager() != null) {
+                                       buildConfig.getCompilationResultDestinationManager().reportFileWrite(outJar.getPath(),
+                                                       CompilationResultDestinationManager.FILETYPE_OUTJAR);
+                               }
                        }
                        zos = null;
 
                        /* Ensure we don't write an incomplete JAR bug-71339 */
                        if (handler.hasErrors()) {
                                outJar.delete();
+                               if (buildConfig.getCompilationResultDestinationManager() != null) {
+                                       buildConfig.getCompilationResultDestinationManager().reportFileRemove(outJar.getPath(),
+                                                       CompilationResultDestinationManager.FILETYPE_OUTJAR);
+                               }
                        }
                } catch (IOException ex) {
                        IMessage message = new Message("Unable to write outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
@@ -552,7 +561,6 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
                }
                if (zos != null) {
                        ZipEntry newEntry = new ZipEntry(filename); // ??? get compression scheme right
-
                        zos.putNextEntry(newEntry);
                        zos.write(content);
                        zos.closeEntry();
@@ -562,9 +570,14 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
                                destDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForResource(srcLocation);
                        }
                        try {
-                               OutputStream fos = FileUtil.makeOutputStream(new File(destDir, filename));
+                               File outputLocation = new File(destDir, filename);
+                               OutputStream fos = FileUtil.makeOutputStream(outputLocation);
                                fos.write(content);
                                fos.close();
+                               if (buildConfig.getCompilationResultDestinationManager() != null) {
+                                       buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputLocation.getPath(),
+                                                       CompilationResultDestinationManager.FILETYPE_RESOURCE);
+                               }
                        } catch (FileNotFoundException fnfe) {
                                IMessage msg = new Message("unable to copy resource to output folder: '" + filename + "' - reason: "
                                                + fnfe.getMessage(), IMessage.ERROR, null, new SourceLocation(srcLocation, 0));
@@ -587,11 +600,17 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
                                // where we sent the classes that were on the inpath
                                outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
                        }
-                       if (outputDir == null)
+                       if (outputDir == null) {
                                return;
-                       OutputStream fos = FileUtil.makeOutputStream(new File(outputDir, MANIFEST_NAME));
+                       }
+                       File outputLocation = new File(outputDir, MANIFEST_NAME);
+                       OutputStream fos = FileUtil.makeOutputStream(outputLocation);
                        manifest.write(fos);
                        fos.close();
+                       if (buildConfig.getCompilationResultDestinationManager() != null) {
+                               buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputLocation.getPath(),
+                                               CompilationResultDestinationManager.FILETYPE_RESOURCE);
+                       }
                }
        }
 
@@ -1083,7 +1102,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour
                                os.write(classFile.getBytes());
                                os.close();
                                if (buildConfig.getCompilationResultDestinationManager() != null) {
-                                       buildConfig.getCompilationResultDestinationManager().reportClassFileWrite(outFile);
+                                       buildConfig.getCompilationResultDestinationManager().reportFileWrite(outFile,
+                                                       CompilationResultDestinationManager.FILETYPE_CLASS);
                                }
                                return outFile;
                        }
index f1339a419520208d52100a85de215019c749f7d2..7c005a045540134144f22b03734fa1fb27a9e143 100644 (file)
@@ -31,6 +31,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
 import org.aspectj.ajdt.internal.compiler.InterimCompilationResult;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.bridge.IMessage;
@@ -1055,6 +1056,10 @@ public class AjState implements CompilerConfigurationChangeFlags {
                                outputLoc = new File(outputLoc, (String) resourcePair.getKey());
                                if (!outputLoc.getPath().equals(sourcePath.getPath()) && outputLoc.exists()) {
                                        outputLoc.delete();
+                                       if (buildConfig.getCompilationResultDestinationManager() != null) {
+                                               buildConfig.getCompilationResultDestinationManager().reportFileRemove(outputLoc.getPath(),
+                                                               CompilationResultDestinationManager.FILETYPE_RESOURCE);
+                                       }
                                }
                        }
                }
@@ -1865,15 +1870,16 @@ public class AjState implements CompilerConfigurationChangeFlags {
                                        for (int i = 0; i < weaverGenerated.length; i++) {
                                                weaverGenerated[i].delete();
                                                if (buildConfig != null && buildConfig.getCompilationResultDestinationManager() != null) {
-                                                       buildConfig.getCompilationResultDestinationManager()
-                                                                       .reportClassFileRemove(weaverGenerated[i].getPath());
+                                                       buildConfig.getCompilationResultDestinationManager().reportFileRemove(weaverGenerated[i].getPath(),
+                                                                       CompilationResultDestinationManager.FILETYPE_CLASS);
                                                }
                                        }
                                }
                        }
                        locationOnDisk.delete();
                        if (buildConfig != null && buildConfig.getCompilationResultDestinationManager() != null) {
-                               buildConfig.getCompilationResultDestinationManager().reportClassFileRemove(locationOnDisk.getPath());
+                               buildConfig.getCompilationResultDestinationManager().reportFileRemove(locationOnDisk.getPath(),
+                                               CompilationResultDestinationManager.FILETYPE_CLASS);
                        }
                }
        }