You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/06/25 05:15:47 UTC

(camel) 03/03: Add properties to skip execution of the validate and route coverage mojos (#13717)

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

davsclaus pushed a commit to branch camel-4.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5374409cb40cc89df52d7e14cf519d0e841dc562
Author: Adriano Machado <60...@users.noreply.github.com>
AuthorDate: Sat Apr 13 01:51:16 2024 -0400

    Add properties to skip execution of the validate and route coverage mojos (#13717)
    
    * Add properties to skip execution of the validate and route coverage mojos
    
    * Fixing typo
    
    * Better log messages
    
    * Adding new parameters to documentation
---
 catalog/camel-report-maven-plugin/pom.xml           | 12 ------------
 .../src/main/docs/camel-report-maven-plugin.adoc    |  2 ++
 .../org/apache/camel/maven/RouteCoverageMojo.java   | 14 ++++++++++++--
 .../java/org/apache/camel/maven/ValidateMojo.java   | 21 ++++++++++++++++-----
 .../ROOT/pages/camel-report-maven-plugin.adoc       |  2 ++
 5 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/catalog/camel-report-maven-plugin/pom.xml b/catalog/camel-report-maven-plugin/pom.xml
index 8557a0e7cd0..ad08c1c7716 100644
--- a/catalog/camel-report-maven-plugin/pom.xml
+++ b/catalog/camel-report-maven-plugin/pom.xml
@@ -55,18 +55,6 @@
             <groupId>org.apache.maven</groupId>
             <artifactId>maven-core</artifactId>
         </dependency>
-        <!-- we extend the exec-maven-plugin for this camel maven plugin -->
-        <dependency>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>exec-maven-plugin</artifactId>
-            <version>${exec-maven-plugin-version}</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.maven</groupId>
-                    <artifactId>maven-plugin-descriptor</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
         <dependency>
             <groupId>org.apache.maven</groupId>
             <artifactId>maven-plugin-api</artifactId>
diff --git a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
index 8e7c682edc0..dbaf6f93c72 100644
--- a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
+++ b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
@@ -133,6 +133,7 @@ The maven plugin *validate* goal supports the following options which can be con
 
 |===
 | Parameter | Default Value | Description
+| skip | false | Whether to skip the plugin execution.
 | downloadVersion | true | Whether to allow downloading Camel catalog version from the internet. This is needed if the project uses a different Camel version than this plugin is using by default.
 | failOnError | false | Whether to fail if invalid Camel endpoints was found. By default the plugin logs the errors at WARN level.
 | coverageThreshold | 100 | The minimum route coverage in percent when using failOnError.
@@ -317,6 +318,7 @@ The maven plugin *coverage* goal supports the following options which can be con
 
 |===
 | Parameter | Default Value | Description
+| skip | false | Whether to skip the plugin execution.
 | failOnError | false | Whether to fail if any of the routes has not 100% coverage.
 | includeTest | false | Whether to include test source code.
 | includes | | To filter the names of java and xml files to only include files matching any of the given list of
diff --git a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java
index 5e27feac9f5..a6d945c753b 100644
--- a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java
+++ b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java
@@ -54,11 +54,11 @@ import org.apache.camel.parser.helper.RouteCoverageHelper;
 import org.apache.camel.parser.model.CamelNodeDetails;
 import org.apache.camel.parser.model.CoverageData;
 import org.apache.camel.util.FileUtil;
+import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
-import org.codehaus.mojo.exec.AbstractExecMojo;
 import org.jboss.forge.roaster.Roaster;
 import org.jboss.forge.roaster.model.JavaType;
 import org.jboss.forge.roaster.model.source.JavaClassSource;
@@ -73,7 +73,7 @@ import static org.apache.camel.maven.ReportPluginCommon.stripRootPath;
  * Performs route coverage reports after running Camel unit tests with camel-test modules
  */
 @Mojo(name = "route-coverage", threadSafe = true)
-public class RouteCoverageMojo extends AbstractExecMojo {
+public class RouteCoverageMojo extends AbstractMojo {
 
     /**
      * The maven project.
@@ -81,6 +81,12 @@ public class RouteCoverageMojo extends AbstractExecMojo {
     @Parameter(property = "project", required = true, readonly = true)
     protected MavenProject project;
 
+    /**
+     * Skip route coverage execution.
+     */
+    @Parameter(property = "camel.skipRouteCoverage", defaultValue = "false")
+    private boolean skip;
+
     /**
      * Whether to fail if a route was not fully covered.
      *
@@ -144,6 +150,10 @@ public class RouteCoverageMojo extends AbstractExecMojo {
 
     @Override
     public void execute() throws MojoExecutionException {
+        if (skip) {
+            getLog().info("skipping route coverage as per configuration");
+            return;
+        }
 
         Set<File> javaFiles = new LinkedHashSet<>();
         Set<File> xmlFiles = new LinkedHashSet<>();
diff --git a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
index 2de29d69d40..2f1d55e1230 100644
--- a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
+++ b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
@@ -45,12 +45,12 @@ import org.apache.camel.util.OrderedProperties;
 import org.apache.camel.util.StringHelper;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
-import org.codehaus.mojo.exec.AbstractExecMojo;
 import org.jboss.forge.roaster.Roaster;
 import org.jboss.forge.roaster.model.JavaType;
 import org.jboss.forge.roaster.model.source.JavaClassSource;
@@ -67,7 +67,7 @@ import static org.apache.camel.maven.ReportPluginCommon.stripRootPath;
  * configuration files such as application.properties.
  */
 @Mojo(name = "validate", threadSafe = true)
-public class ValidateMojo extends AbstractExecMojo {
+public class ValidateMojo extends AbstractMojo {
 
     /**
      * The maven project.
@@ -76,7 +76,13 @@ public class ValidateMojo extends AbstractExecMojo {
     protected MavenProject project;
 
     /**
-     * Whether to fail if invalid Camel endpoints was found. By default the plugin logs the errors at WARN level
+     * Skip the validation execution.
+     */
+    @Parameter(property = "camel.skipValidation", defaultValue = "false")
+    private boolean skip;
+
+    /**
+     * Whether to fail if invalid Camel endpoints was found. By default, the plugin logs the errors at WARN level
      */
     @Parameter(property = "camel.failOnError", defaultValue = "false")
     private boolean failOnError;
@@ -166,7 +172,7 @@ public class ValidateMojo extends AbstractExecMojo {
     private boolean duplicateRouteId;
 
     /**
-     * Whether to validate direct/seda endpoints sending to non existing consumers.
+     * Whether to validate direct/seda endpoints sending to non-existing consumers.
      */
     @Parameter(property = "camel.directOrSedaPairCheck", defaultValue = "true")
     private boolean directOrSedaPairCheck;
@@ -175,11 +181,16 @@ public class ValidateMojo extends AbstractExecMojo {
      * Location of configuration files to validate. The default is application.properties Multiple values can be
      * separated by comma and use wildcard pattern matching.
      */
-    @Parameter(property = "camel.configurationFiles")
+    @Parameter(property = "camel.configurationFiles", defaultValue = "application.properties")
     private String configurationFiles = "application.properties";
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
+        if (skip) {
+            getLog().info("skipping route validation as per configuration");
+            return;
+        }
+
         CamelCatalog catalog = new DefaultCamelCatalog();
         // add activemq as known component
         catalog.addComponent("activemq", "org.apache.activemq.camel.component.ActiveMQComponent");
diff --git a/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc b/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc
index 3b8338b2faa..d6483fac770 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc
@@ -70,6 +70,7 @@ The maven plugin *validate* goal supports the following options which can be con
 
 |===
 | Parameter | Default Value | Description
+| skip | false | Whether to skip the plugin execution.
 | downloadVersion | true | Whether to allow downloading Camel catalog version from the internet. This is needed if the project uses a different Camel version than this plugin is using by default.
 | failOnError | false | Whether to fail if invalid Camel endpoints was found. By default the plugin logs the errors at WARN level.
 | coverageThreshold | 100 | The minimum route coverage in percent when using failOnError.
@@ -254,6 +255,7 @@ The maven plugin *coverage* goal supports the following options which can be con
 
 |===
 | Parameter | Default Value | Description
+| skip | false | Whether to skip the plugin execution.
 | failOnError | false | Whether to fail if any of the routes has not 100% coverage.
 | includeTest | false | Whether to include test source code.
 | includes | | To filter the names of java and xml files to only include files matching any of the given list of