Codebase list jarjar-maven-plugin / upstream/1.9
Imported Upstream version 1.9 Emmanuel Bourg 10 years ago
2 changed file(s) with 43 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
55 <parent>
66 <groupId>org.sonatype.plugins</groupId>
77 <artifactId>plugins-parent</artifactId>
8 <version>8</version>
8 <version>9</version>
99 </parent>
1010
1111 <packaging>maven-plugin</packaging>
1212
1313 <groupId>org.sonatype.plugins</groupId>
1414 <artifactId>jarjar-maven-plugin</artifactId>
15 <version>1.8</version>
15 <version>1.9</version>
1616
1717 <name>JarJar Maven Plugin</name>
1818
3131 <connection>scm:git:git@github.com:sonatype/jarjar-maven-plugin.git</connection>
3232 <developerConnection>scm:git:git@github.com:sonatype/jarjar-maven-plugin.git</developerConnection>
3333 <url>http://github.com/sonatype/jarjar-maven-plugin</url>
34 <tag>jarjar-maven-plugin-1.9</tag>
3435 </scm>
3536
3637 <ciManagement>
4950 <properties>
5051 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5152 <forgeReleaseUrl>https://repository.sonatype.org/service/local/staging/deploy/maven2</forgeReleaseUrl>
52 <asm.version>4.0</asm.version>
53 <asm.version>5.0.1</asm.version>
5354 </properties>
5455
5556 <dependencies>
8788 <dependency>
8889 <groupId>org.codehaus.plexus</groupId>
8990 <artifactId>plexus-archiver</artifactId>
90 <version>2.1.2</version>
91 <version>2.4.4</version>
9192 </dependency>
9293 <dependency>
9394 <groupId>org.codehaus.plexus</groupId>
9495 <artifactId>plexus-utils</artifactId>
95 <version>3.0.5</version>
96 <version>3.0.15</version>
9697 </dependency>
9798 </dependencies>
9899
99100 <build>
100101 <plugins>
102 <plugin>
103 <artifactId>maven-release-plugin</artifactId>
104 <version>2.5</version>
105 </plugin>
101106 <plugin>
102107 <artifactId>maven-site-plugin</artifactId>
103108 <version>3.1</version>
6969 final ArrayList<ZipEntry> sortedList = new ArrayList<ZipEntry>();
7070 while (e.hasMoreElements()) {
7171 final ZipEntry entry = e.nextElement();
72 sortedList.add(entry);
72 // META-INF/ doesn't need a directory entry
73 if (!"META-INF/".equals(entry.getName())) {
74 sortedList.add(entry);
75 }
7376 }
7477
7578 Collections.sort(sortedList, new Comparator<ZipEntry>()
7679 {
7780 public int compare(ZipEntry o1, ZipEntry o2)
7881 {
79 return o1.getName().compareTo(o2.getName());
82 String n1 = o1.getName(), n2 = o2.getName();
83 if (metaOverride(n1, n2)) {
84 return -1;
85 }
86 if (metaOverride(n2, n1)) {
87 return 1;
88 }
89 return n1.compareTo(n2);
90 }
91
92 // make sure that META-INF/MANIFEST.MF is always the very first entry
93 private boolean metaOverride(String n1, String n2) {
94 return (n1.startsWith("META-INF/") && !n2.startsWith("META-INF/"))
95 || (n1.equals("META-INF/MANIFEST.MF") && !n2.equals(n1));
8096 }
8197 });
8298
104120 isEmptyDirectory = false;
105121 }
106122
107
108 // write the entry
109123 if (isEmptyDirectory)
110124 {
111 sortedList.remove(inputEntry);
125 sortedList.remove(i);
112126 }
113 else
114 {
115 final ZipEntry outputEntry = new ZipEntry(inputEntry);
116 outputStream.putNextEntry(outputEntry);
117 ByteArrayOutputStream baos = new ByteArrayOutputStream();
118 final InputStream is = inputZip.getInputStream(inputEntry);
119 IoUtil.pipe(is, baos, buf);
120 is.close();
121 outputStream.write(baos.toByteArray());
122 }
127 }
128
129 // finally write entries in normal order
130 for (int i = 0; i < sortedList.size(); i++)
131 {
132 final ZipEntry inputEntry = sortedList.get(i);
133 final ZipEntry outputEntry = new ZipEntry(inputEntry);
134 outputStream.putNextEntry(outputEntry);
135 ByteArrayOutputStream baos = new ByteArrayOutputStream();
136 final InputStream is = inputZip.getInputStream(inputEntry);
137 IoUtil.pipe(is, baos, buf);
138 is.close();
139 outputStream.write(baos.toByteArray());
123140 }
124141 } finally {
125142 outputStream.close();
143 inputZip.close();
126144 }
127145
128146 }