@@ -182,26 +182,23 @@ protected void postWriteEntry(JarOutputStream jarOut, String entryName) throws I
182
182
protected void postWrite (JarOutputStream jarOut ) throws IOException
183
183
{
184
184
File file = ((DelayedFile )this .injectDir ).call ();
185
- File info = new File (file , "package-info-template.java" );
186
- if (info .exists ())
187
- {
188
- String template = Resources .toString (info .toURI ().toURL (), Charsets .UTF_8 );
189
- getLogger ().debug ("Adding package-infos" );
190
- for (String pkg : this .seenPackages )
191
- {
192
- jarOut .putNextEntry (new ZipEntry (pkg + "/package-info.java" ));
193
- jarOut .write (template .replaceAll ("\\ {PACKAGE\\ }" , pkg .replace ('/' , '.' )).getBytes ());
194
- jarOut .closeEntry ();
195
- }
196
- }
197
185
198
- for (File f : this .getProject ().fileTree (info ))
199
- {
200
- if ("package-info-template.java" .equals (f .getName ())) continue ;
201
- String name = f .getAbsolutePath ().substring (info .getAbsolutePath ().length () + 1 ).replace ('\\' , '/' );
202
- jarOut .putNextEntry (new ZipEntry (name ));
203
- jarOut .write (Resources .toByteArray (f .toURI ().toURL ()));
204
- jarOut .closeEntry ();
186
+ for (File f : getProject ().fileTree (file )) {
187
+ if ("package-info-template.java" .equals (f .getName ())) {
188
+ String template = Files .toString (f , Charsets .UTF_8 );
189
+ getLogger ().debug ("Adding package-infos" );
190
+
191
+ for (String pkg : seenPackages ) {
192
+ jarOut .putNextEntry (new ZipEntry (pkg + "/package-info.java" ));
193
+ jarOut .write (template .replaceAll ("\\ {PACKAGE\\ }" , pkg .replace ('/' , '.' )).getBytes ());
194
+ jarOut .closeEntry ();
195
+ }
196
+ } else {
197
+ String name = f .getAbsolutePath ().substring (file .getAbsolutePath ().length () + 1 ).replace ('\\' , '/' );
198
+ jarOut .putNextEntry (new ZipEntry (name ));
199
+ jarOut .write (Files .asByteSource (f ).read ());
200
+ jarOut .closeEntry ();
201
+ }
205
202
}
206
203
}
207
204
0 commit comments