You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2019/09/04 21:01:57 UTC

[camel] 03/16: CAMEL-13246: Add Maven GAV to spring-boot auto configuration doc

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

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

commit 58c7b77e0739d2078cb81fad128022df307efef4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Feb 22 08:05:32 2019 +0100

    CAMEL-13246: Add Maven GAV to spring-boot auto configuration doc
    
    (cherry picked from commit f43292644985311373c33b53d17317333394b218)
    
    # Conflicts:
    #	tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java
---
 ...pdateSpringBootAutoConfigurationReadmeMojo.java | 19 ++++---
 .../maven/packaging/model/SpringBootModel.java     | 60 ++++++++++++++++++++++
 .../spring-boot-auto-configure-options.mvel        | 20 ++++++--
 3 files changed, 89 insertions(+), 10 deletions(-)

diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java
index 490d5f8..a0828d7 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java
@@ -28,6 +28,7 @@ import java.util.Locale;
 import java.util.stream.Collectors;
 
 import org.apache.camel.maven.packaging.model.SpringBootAutoConfigureOptionModel;
+import org.apache.camel.maven.packaging.model.SpringBootModel;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -178,8 +179,8 @@ public class UpdateSpringBootAutoConfigurationReadmeMojo extends AbstractMojo {
                             throw new MojoExecutionException("Failed build due failOnMissingDescription=true");
                         }
 
-                        String options = templateAutoConfigurationOptions(models);
-                        boolean updated = updateAutoConfigureOptions(docFile, options);
+                        String changed = templateAutoConfigurationOptions(models, componentName);
+                        boolean updated = updateAutoConfigureOptions(docFile, changed);
                         if (updated) {
                             getLog().info("Updated doc file: " + docFile);
                         } else {
@@ -207,8 +208,8 @@ public class UpdateSpringBootAutoConfigurationReadmeMojo extends AbstractMojo {
                                 throw new MojoExecutionException("Failed build due failOnMissingDescription=true");
                             }
 
-                            String options = templateAutoConfigurationOptions(models);
-                            boolean updated = updateAutoConfigureOptions(docFile, options);
+                            String changed = templateAutoConfigurationOptions(models, componentName);
+                            boolean updated = updateAutoConfigureOptions(docFile, changed);
                             if (updated) {
                                 getLog().info("Updated doc file: " + docFile);
                             } else {
@@ -363,10 +364,16 @@ public class UpdateSpringBootAutoConfigurationReadmeMojo extends AbstractMojo {
         }
     }
 
-    private String templateAutoConfigurationOptions(List<SpringBootAutoConfigureOptionModel> options) throws MojoExecutionException {
+    private String templateAutoConfigurationOptions(List<SpringBootAutoConfigureOptionModel> options, String componentName) throws MojoExecutionException {
+        SpringBootModel model = new SpringBootModel();
+        model.setGroupId(project.getGroupId());
+        model.setArtifactId("camel-" + componentName + "-starter");
+        model.setVersion(project.getVersion());
+        model.setOptions(options);
+
         try {
             String template = loadText(UpdateSpringBootAutoConfigurationReadmeMojo.class.getClassLoader().getResourceAsStream("spring-boot-auto-configure-options.mvel"));
-            String out = (String) TemplateRuntime.eval(template, options);
+            String out = (String) TemplateRuntime.eval(template, model);
             return out;
         } catch (Exception e) {
             throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/SpringBootModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/SpringBootModel.java
new file mode 100644
index 0000000..0f6af2e
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/SpringBootModel.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.packaging.model;
+
+import java.util.List;
+
+public class SpringBootModel {
+
+    private String groupId;
+    private String artifactId;
+    private String version;
+
+    private List<SpringBootAutoConfigureOptionModel> options;
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public void setArtifactId(String artifactId) {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public List<SpringBootAutoConfigureOptionModel> getOptions() {
+        return options;
+    }
+
+    public void setOptions(List<SpringBootAutoConfigureOptionModel> options) {
+        this.options = options;
+    }
+}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/spring-boot-auto-configure-options.mvel b/tooling/maven/camel-package-maven-plugin/src/main/resources/spring-boot-auto-configure-options.mvel
index 47f07e2..3b41a93 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/resources/spring-boot-auto-configure-options.mvel
+++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/spring-boot-auto-configure-options.mvel
@@ -1,15 +1,27 @@
 === Spring Boot Auto-Configuration
 
-@if{this.isEmpty()}
+When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
+
+[source,xml]
+----
+<dependency>
+  <groupId>@{groupId}</groupId>
+  <artifactId>@{artifactId}</artifactId>
+  <version>x.x.x</version>
+  <!-- use the same version as your Camel core version -->
+</dependency>
+----
+
+@if{options.isEmpty()}
 The component has no Spring Boot auto configuration options.
 @else{}
-The component supports @{this.size()} options, which are listed below.
+The component supports @{options.size()} options, which are listed below.
 @end{}
 
-@if{!this.isEmpty()}
+@if{!options.isEmpty()}
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-@foreach{row : this}| *@{row.name}* | @{row.description} | @{row.getShortDefaultValue(20)} | @{row.getShortJavaType(25)}
+@foreach{row : options}| *@{row.name}* | @{row.description} | @{row.getShortDefaultValue(20)} | @{row.getShortJavaType(25)}
 @end{}|===
 @end{}
\ No newline at end of file