]> source.dussan.org Git - aspectj.git/commitdiff
203235: test and fix
authoraclement <aclement>
Fri, 22 Aug 2008 01:32:33 +0000 (01:32 +0000)
committeraclement <aclement>
Fri, 22 Aug 2008 01:32:33 +0000 (01:32 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java

index fd490009c5a9d44c7726feebbecdc207237b1deb..4a99f6728308eeaf7723d8d1eae6697292f4013d 100644 (file)
@@ -467,8 +467,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                        
                                String filename = entry.getName();
 //                             System.out.println("? copyResourcesFromJarFile() filename='" + filename +"'");
-       
-                               if (!entry.isDirectory() && acceptResource(filename,false)) {
+                               if (entry.isDirectory()) {
+                                       writeDirectory(filename,jarFile);
+                               } else if (acceptResource(filename,false)) {
                                        byte[] bytes = FileUtil.readAsByteArray(inStream);
                                        writeResource(filename,bytes,jarFile);
                                }
@@ -514,6 +515,32 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                }       
        }
     
+       /**
+        * Add a directory entry to the output zip file.  Don't do anything if not writing out to 
+        * a zip file.  A directory entry is one whose filename ends with '/'
+        * 
+        * @param directory the directory path
+        * @param srcloc the src of the directory entry, for use when creating a warning message
+        * @throws IOException if something goes wrong creating the new zip entry
+        */
+       private void writeDirectory(String directory, File srcloc) throws IOException {
+               if (state.hasResource(directory)) {
+                       IMessage msg = new Message("duplicate resource: '" + directory + "'",
+                                          IMessage.WARNING,
+                                          null,
+                                          new SourceLocation(srcloc,0));
+                       handler.handleMessage(msg);
+                       return;
+               }
+               if (zos != null) {
+                       ZipEntry newEntry = new ZipEntry(directory);
+                       zos.putNextEntry(newEntry);
+                       zos.closeEntry();
+                       state.recordResource(directory);
+               }
+               // Nothing to do if not writing to a zip file
+       }
+       
        private void writeResource(String filename, byte[] content, File srcLocation) throws IOException {
                if (state.hasResource(filename)) {
                        IMessage msg = new Message("duplicate resource: '" + filename + "'",