Bladeren bron

generalize report API to cover resources and outjar

tags/V1_6_4
aclement 15 jaren geleden
bovenliggende
commit
c53218321b

+ 25
- 5
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java Bestand weergeven

@@ -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;
}

+ 9
- 3
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java Bestand weergeven

@@ -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);
}
}
}

Laden…
Annuleren
Opslaan