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 2021/02/08 15:18:51 UTC

[camel] branch master updated: prepare-example goal should be configurable so it can work for camel-example and camel-example-spring-boot

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b82e64a  prepare-example goal should be configurable so it can work for camel-example and camel-example-spring-boot
b82e64a is described below

commit b82e64a3ebe10289baad58cf624dcc14720ef301
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Feb 8 16:18:10 2021 +0100

    prepare-example goal should be configurable so it can work for camel-example and camel-example-spring-boot
---
 .../camel/maven/packaging/PrepareExampleMojo.java  | 24 +++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareExampleMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareExampleMojo.java
index a82f3a9..4a342c3 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareExampleMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareExampleMojo.java
@@ -56,6 +56,12 @@ public class PrepareExampleMojo extends AbstractMojo {
     @Parameter(property = "project", required = true, readonly = true)
     protected MavenProject project;
 
+    @Parameter(property = "startingFolder", required = true, readonly = true, defaultValue = "examples")
+    protected String startingFolder = "examples";
+
+    @Parameter(property = "filter", required = true, readonly = true, defaultValue = "camel-example")
+    protected String filter = "camel-example";
+
     /**
      * Maven ProjectHelper.
      */
@@ -76,11 +82,12 @@ public class PrepareExampleMojo extends AbstractMojo {
     protected void executeExamplesReadme() throws MojoExecutionException, MojoFailureException {
         Set<File> examples = new TreeSet<>();
 
-        // only run in examples directory where the main readme.adoc file is
-        // located
         String currentDir = Paths.get(".").normalize().toAbsolutePath().toString();
-        if (!currentDir.endsWith("examples")) {
-            return;
+        if (startingFolder != null && !startingFolder.isEmpty()) {
+            // only run in examples directory where the main readme.adoc file is located
+            if (!currentDir.endsWith("examples")) {
+                return;
+            }
         }
 
         File dir = new File(".");
@@ -93,8 +100,15 @@ public class PrepareExampleMojo extends AbstractMojo {
             List<ExampleModel> models = new ArrayList<>();
 
             for (File file : examples) {
+                if (file.isDirectory()) {
+
+                    // must match filter
+                    if (filter != null && !filter.isEmpty()) {
+                        if (!file.getName().startsWith(filter)) {
+                            continue;
+                        }
+                    }
 
-                if (file.isDirectory() && file.getName().startsWith("camel-example")) {
                     File pom = new File(file, "pom.xml");
                     if (pom.exists()) {
                         String existing = FileUtils.readFileToString(pom, Charset.defaultCharset());