camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] branch master updated: CAMEL-12841: camel-restdsl-swagger:generate - Special case for Spring Boot with servlet component to generate CamelRestController support class to allow using root context-path and spring boot health check/actuators at the same time.
Date Tue, 02 Oct 2018 14:16:10 GMT
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 16a3eed  CAMEL-12841: camel-restdsl-swagger:generate - Special case for Spring Boot
with servlet component to generate CamelRestController support class to allow using root context-path
and spring boot health check/actuators at the same time.
16a3eed is described below

commit 16a3eed1ad0393c79e410f30460bc811772b57ca
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Tue Oct 2 16:13:23 2018 +0200

    CAMEL-12841: camel-restdsl-swagger:generate - Special case for Spring Boot with servlet
component to generate CamelRestController support class to allow using root context-path and
spring boot health check/actuators at the same time.
---
 .../src/main/docs/camel-restdsl-swagger-plugin.adoc         |  6 +++---
 .../apache/camel/maven/generator/swagger/GenerateMojo.java  | 13 ++++++++-----
 .../camel/maven/generator/swagger/GenerateXmlMojo.java      |  6 +++++-
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
index 8f89e62..8ecb722 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
@@ -72,9 +72,9 @@ in the `<configuration>` tag.
 === Spring Boot Project with Servlet component
 
 If the Maven project is a Spring Boot project and `restConfiguration` is enabled and the
servlet component
-is being used as REST component, then this plugin will
-autodetect the package name where the `@SpringBootApplication` main class is located, and
use the same
-package name for generating Rest DSL source code and a needed `CamelRestController` support
class.
+is being used as REST component, then this plugin will autodetect the package name (if packageName
has not been explicit configured)
+ where the `@SpringBootApplication` main class is located, and use the same package name
+ for generating Rest DSL source code and a needed `CamelRestController` support class.
 
 == camel-restdsl-swagger:generate-with-dto
 
diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
index 33e0173..41aaa94 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
@@ -122,11 +122,14 @@ public class GenerateMojo extends AbstractGenerateMojo {
             // if its a spring boot project and we use servlet then we should generate additional
source code
             if (detectSpringBootFromClasspath() && "servlet".equals(comp)) {
                 try {
-                    String pName = detectSpringBootMainPackage();
-                    if (pName != null) {
-                        packageName = pName;
-                        generator.withPackageName(packageName);
-                        getLog().info("Detected @SpringBootApplication, and will be using
its package name: " + packageName);
+                    if (ObjectHelper.isEmpty(packageName)) {
+                        // if not explicit package name then try to use package where the
spring boot application is located
+                        String pName = detectSpringBootMainPackage();
+                        if (pName != null) {
+                            packageName = pName;
+                            generator.withPackageName(packageName);
+                            getLog().info("Detected @SpringBootApplication, and will be using
its package name: " + packageName);
+                        }
                     }
                     getLog().info("Generating Camel Rest Controller source with package name
" + packageName + " in source directory: " + outputPath);
                     SpringBootProjectSourceCodeGenerator.generator().withPackageName(packageName).generate(outputPath);
diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
index 3c7953c..6ec6ad1 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
@@ -18,6 +18,7 @@ package org.apache.camel.maven.generator.swagger;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 
 import io.swagger.models.Swagger;
 import io.swagger.parser.SwaggerParser;
@@ -25,6 +26,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.generator.swagger.DestinationGenerator;
 import org.apache.camel.generator.swagger.RestDslGenerator;
 import org.apache.camel.generator.swagger.RestDslXmlGenerator;
+import org.apache.camel.generator.swagger.SpringBootProjectSourceCodeGenerator;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -83,6 +85,8 @@ public class GenerateXmlMojo extends AbstractGenerateMojo {
                 getLog().info("Detected Camel Rest component from classpath: " + comp);
                 generator.withRestComponent(comp);
             } else {
+                comp = "servlet";
+
                 // is it spring boot?
                 String aid = "camel-servlet";
                 if (detectSpringBootFromClasspath()) {
@@ -101,7 +105,7 @@ public class GenerateXmlMojo extends AbstractGenerateMojo {
                 getLog().info("Cannot detect Rest component from classpath. Will use servlet
as Rest component.");
                 getLog().info("Add the following dependency in the Maven pom.xml file:\n"
+ dep + "\n");
 
-                generator.withRestComponent("servlet");
+                generator.withRestComponent(comp);
             }
         }
 


Mime
View raw message