This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ba0fcd  SLING-8796 : Continue with api generation even if javadoc 
reports errors
5ba0fcd is described below

commit 5ba0fcd243e96ad739ff9ed4a8b3fadc627aa152
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Wed Oct 23 07:33:22 2019 +0200

    SLING-8796 : Continue with api generation even if javadoc reports errors
---
 .../org/apache/sling/feature/maven/mojos/ApisJarMojo.java | 15 +++++++++++----
 .../apache/sling/feature/maven/mojos/JavadocExecutor.java |  4 ++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java 
b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
index 9b2ad22..4a85f5d 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
@@ -125,6 +125,9 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
 
     private static final String SPACE = " ";
 
+    /**
+     * Select the features for api generation.
+     */
     @Parameter
     private FeatureSelectionConfig selection;
 
@@ -149,6 +152,9 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
     @Parameter
     private String[] javadocLinks;
 
+    @Parameter(defaultValue = "false")
+    private boolean ignoreJavadocErrors;
+
     /**
      * Additional resources for the api jar
      */
@@ -353,7 +359,7 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
 
             if (sourcesDir.list().length > 0) {
                 File javadocsDir = new File(regionDir, JAVADOC);
-                generateJavadoc(apiRegion, sourcesDir, javadocsDir, 
javadocClasspath);
+                generateJavadoc(sourcesDir, javadocsDir, javadocClasspath);
                 createArchive(feature.getId(), javadocsDir, apiRegion, 
JAVADOC, null, this.apiJavadocResources);
             } else {
                 getLog().warn("Javadoc JAR will NOT be generated - sources 
directory was empty!");
@@ -869,7 +875,7 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
 
     /**
      * Compute exports based on api regions
-     * 
+     *
      * @return {@code true} if any region exports a package from this set
      */
     private boolean computeExports(List<ApiRegion> apiRegions, final Clause[] 
exportedPackages)
@@ -1018,7 +1024,8 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
         }
     }
 
-    private void generateJavadoc(ApiRegion apiRegion, File sourcesDir, File 
javadocDir, Set<String> javadocClasspath) throws MojoExecutionException {
+    private void generateJavadoc(File sourcesDir, File javadocDir, Set<String> 
javadocClasspath)
+            throws MojoExecutionException {
         javadocDir.mkdirs();
 
         JavadocExecutor javadocExecutor = new 
JavadocExecutor(javadocDir.getParentFile())
@@ -1070,7 +1077,7 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
         javadocExecutor.addArgument(sourcesDir.list(), File.pathSeparator);
 
         // .addArgument("-J-Xmx2048m")
-        javadocExecutor.execute(javadocDir, getLog());
+        javadocExecutor.execute(javadocDir, getLog(), 
this.ignoreJavadocErrors);
     }
 
     private static ArtifactId newArtifacId(ArtifactId original, String 
classifier, String type) {
diff --git 
a/src/main/java/org/apache/sling/feature/maven/mojos/JavadocExecutor.java 
b/src/main/java/org/apache/sling/feature/maven/mojos/JavadocExecutor.java
index fcd6d9b..d5922a7 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/JavadocExecutor.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/JavadocExecutor.java
@@ -95,7 +95,7 @@ final class JavadocExecutor {
         return this;
     }
 
-    public void execute(File workingDir, Log logger) throws 
MojoExecutionException {
+    public void execute(File workingDir, Log logger, boolean ignoreErrors) 
throws MojoExecutionException {
         argFileWriter.close();
 
         CommandLine javadocCommand = new CommandLine(getJavadocExecutable());
@@ -108,7 +108,7 @@ final class JavadocExecutor {
         try {
             executor.getStreamHandler().setProcessInputStream(new 
LoggerOutputStream(logger));
             final int exitValue = executor.execute(javadocCommand);
-            if (executor.isFailure(exitValue)) {
+            if (!ignoreErrors && executor.isFailure(exitValue)) {
                 throw new MojoExecutionException("Javadoc generation failed. 
See log for more details.");
             }
         } catch (IOException ioe) {

Reply via email to