@@ -221,23 +221,14 @@ protected String getClassifier() {
221
221
* @throws IOException {@link IOException}
222
222
*/
223
223
private File generateArchive (File javadocFiles , String jarFileName ) throws ArchiverException , IOException {
224
- File javadocJar = new File (jarOutputDirectory , jarFileName );
225
-
226
- if (javadocJar .exists ()) {
227
- javadocJar .delete ();
228
- }
229
-
230
224
MavenArchiver archiver = new MavenArchiver ();
231
- archiver .setCreatedBy ("Maven Javadoc Plugin" , "org.apache.maven.plugins" , "maven-javadoc-plugin" );
232
225
archiver .setArchiver (jarArchiver );
233
- archiver .setOutputFile ( javadocJar );
226
+ archiver .setCreatedBy ( "Maven Javadoc Plugin" , "org.apache.maven.plugins" , "maven-javadoc-plugin" );
234
227
235
228
// configure for Reproducible Builds based on outputTimestamp value
236
229
archiver .configureReproducibleBuild (outputTimestamp );
237
230
238
- if (!javadocFiles .exists ()) {
239
- getLog ().warn ("JAR will be empty - no content was marked for inclusion!" );
240
- } else {
231
+ if (javadocFiles .exists ()) {
241
232
archiver .getArchiver ().addDirectory (javadocFiles , DEFAULT_INCLUDES , DEFAULT_EXCLUDES );
242
233
}
243
234
@@ -254,14 +245,20 @@ private File generateArchive(File javadocFiles, String jarFileName) throws Archi
254
245
archive .setManifestFile (defaultManifestFile );
255
246
}
256
247
248
+ File outputFile = new File (jarOutputDirectory , jarFileName );
249
+
250
+ // Why do we do this?
251
+ if (outputFile .exists ()) {
252
+ outputFile .delete ();
253
+ }
254
+ archiver .setOutputFile (outputFile );
255
+
257
256
try {
258
257
archiver .createArchive (session , project , archive );
259
- } catch (ManifestException e ) {
260
- throw new ArchiverException ("ManifestException: " + e .getMessage (), e );
261
- } catch (DependencyResolutionRequiredException e ) {
262
- throw new ArchiverException ("DependencyResolutionRequiredException: " + e .getMessage (), e );
258
+ } catch (ManifestException | DependencyResolutionRequiredException e ) {
259
+ throw new ArchiverException ("Error creating Javadoc archive: " + e .getMessage (), e );
263
260
}
264
261
265
- return javadocJar ;
262
+ return outputFile ;
266
263
}
267
264
}
0 commit comments