diff options
author | acolyer <acolyer> | 2004-03-17 12:25:49 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-03-17 12:25:49 +0000 |
commit | 34dbb0c41b3e324e3c7fc5a150c314fbecfd5e6e (patch) | |
tree | b1150ee6eda37e251eb161a87492f9cdde0ac6aa /weaver | |
parent | 90fbe5d804038002cc651421a5bc94a2b20f7e70 (diff) | |
download | aspectj-34dbb0c41b3e324e3c7fc5a150c314fbecfd5e6e.tar.gz aspectj-34dbb0c41b3e324e3c7fc5a150c314fbecfd5e6e.zip |
fix for Bugzilla Bug 47910
ajc -outjar jarfile does not contain MANIFEST.MF
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index 7cc91555b..d900c2035 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -25,12 +25,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; +import java.util.jar.Attributes; +import java.util.jar.Attributes.Name; +import java.util.jar.JarInputStream; +import java.util.jar.Manifest; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; @@ -80,7 +82,8 @@ public class BcelWeaver implements IWeaver { // private Map sourceJavaClasses = new HashMap(); /* String -> UnwovenClassFile */ private List addedClasses = new ArrayList(); /* List<UnovenClassFile> */ private List deletedTypenames = new ArrayList(); /* List<String> */ -// private Map resources = new HashMap(); /* String -> UnwovenClassFile */ +// private Map resources = new HashMap(); /* String -> UnwovenClassFile */ + private Manifest manifest = null; private boolean needToReweaveWorld = false; private List shadowMungerList = null; // setup by prepareForWeave @@ -142,8 +145,8 @@ public class BcelWeaver implements IWeaver { } - // The ANT copy task should be used to copy resources across. - private final static boolean CopyResourcesFromInpathDirectoriesToOutput=false; +// // The ANT copy task should be used to copy resources across. +// private final static boolean CopyResourcesFromInpathDirectoriesToOutput=false; private Set alreadyConfirmedReweavableState; /** @@ -197,7 +200,7 @@ public class BcelWeaver implements IWeaver { // System.err.println("? addJarFile(" + inFile + ", " + outDir + ")"); List addedClassFiles = new ArrayList(); needToReweaveWorld = true; - ZipInputStream inStream = null; + JarInputStream inStream = null; try { // Is this a directory we are looking at? @@ -205,7 +208,8 @@ public class BcelWeaver implements IWeaver { addedClassFiles.addAll(addDirectoryContents(inFile,outDir)); } else { - inStream = new ZipInputStream(new FileInputStream(inFile)); //??? buffered + inStream = new JarInputStream(new FileInputStream(inFile)); //??? buffered + addManifest(inStream.getManifest()); while (true) { ZipEntry entry = inStream.getNextEntry(); @@ -387,6 +391,29 @@ public class BcelWeaver implements IWeaver { // dumpResourcesToOutJar(); // } + public void addManifest (Manifest newManifest) { + if (manifest == null) { + manifest = newManifest; + } + } + + private static final String WEAVER_MANIFEST_VERSION = "1.0"; + private static final Attributes.Name CREATED_BY = new Name("Created-By"); + private static final String WEAVER_CREATED_BY = "AspectJ Compiler"; + + public Manifest getManifest (boolean shouldCreate) { + + if (manifest == null && shouldCreate) { + manifest = new Manifest(); + + Attributes attributes = manifest.getMainAttributes(); + attributes.put(Name.MANIFEST_VERSION,WEAVER_MANIFEST_VERSION); + attributes.put(CREATED_BY,WEAVER_CREATED_BY); + } + + return manifest; + } + // ---- weaving // Used by some test cases only... |