@@ -221,23 +221,14 @@ protected String getClassifier() {
221221 * @throws IOException {@link IOException}
222222 */
223223 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-
230224 MavenArchiver archiver = new MavenArchiver ();
231- archiver .setCreatedBy ("Maven Javadoc Plugin" , "org.apache.maven.plugins" , "maven-javadoc-plugin" );
232225 archiver .setArchiver (jarArchiver );
233- archiver .setOutputFile ( javadocJar );
226+ archiver .setCreatedBy ( "Maven Javadoc Plugin" , "org.apache.maven.plugins" , "maven-javadoc-plugin" );
234227
235228 // configure for Reproducible Builds based on outputTimestamp value
236229 archiver .configureReproducibleBuild (outputTimestamp );
237230
238- if (!javadocFiles .exists ()) {
239- getLog ().warn ("JAR will be empty - no content was marked for inclusion!" );
240- } else {
231+ if (javadocFiles .exists ()) {
241232 archiver .getArchiver ().addDirectory (javadocFiles , DEFAULT_INCLUDES , DEFAULT_EXCLUDES );
242233 }
243234
@@ -254,14 +245,20 @@ private File generateArchive(File javadocFiles, String jarFileName) throws Archi
254245 archive .setManifestFile (defaultManifestFile );
255246 }
256247
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+
257256 try {
258257 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 );
263260 }
264261
265- return javadocJar ;
262+ return outputFile ;
266263 }
267264}
0 commit comments