Repository: camel Updated Branches: refs/heads/master 25410ef00 -> 11469adce
CAMEL-10122: Spring Boot auto configuration - fixed some duplicate name clashes Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/11469adc Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/11469adc Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/11469adc Branch: refs/heads/master Commit: 11469adce650e883ac23de1bdb65d9d4052ed59c Parents: 25410ef Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Jul 6 09:05:36 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Jul 6 09:20:41 2016 +0200 ---------------------------------------------------------------------- .../ws/springboot/WsComponentConfiguration.java | 2 +- .../CometdComponentConfiguration.java | 2 +- .../springboot/HttpComponentConfiguration.java | 2 +- .../springboot/MailComponentConfiguration.java | 2 +- .../springboot/SmppComponentConfiguration.java | 2 +- .../SpringBootAutoConfigurationMojo.java | 30 ++++++++++++++++++-- 6 files changed, 32 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/11469adc/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/springboot/WsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/springboot/WsComponentConfiguration.java b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/springboot/WsComponentConfiguration.java index 7c57d08..faa0542 100644 --- a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/springboot/WsComponentConfiguration.java +++ b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/springboot/WsComponentConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * * Generated by camel-package-maven-plugin - do not edit this file! */ -@ConfigurationProperties(prefix = "camel.component.ahc-wss") +@ConfigurationProperties(prefix = "camel.component.ahc-ws") public class WsComponentConfiguration { /** http://git-wip-us.apache.org/repos/asf/camel/blob/11469adc/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConfiguration.java b/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConfiguration.java index 6d7c7d0..c499e61 100644 --- a/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConfiguration.java +++ b/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * * Generated by camel-package-maven-plugin - do not edit this file! */ -@ConfigurationProperties(prefix = "camel.component.cometds") +@ConfigurationProperties(prefix = "camel.component.cometd") public class CometdComponentConfiguration { /** http://git-wip-us.apache.org/repos/asf/camel/blob/11469adc/components/camel-http/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java b/components/camel-http/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java index 0ce100e..e1eb6b6 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * * Generated by camel-package-maven-plugin - do not edit this file! */ -@ConfigurationProperties(prefix = "camel.component.https") +@ConfigurationProperties(prefix = "camel.component.http") public class HttpComponentConfiguration { /** http://git-wip-us.apache.org/repos/asf/camel/blob/11469adc/components/camel-mail/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java index 7b332f1..7b150d1 100644 --- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java +++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java @@ -25,7 +25,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * * Generated by camel-package-maven-plugin - do not edit this file! */ -@ConfigurationProperties(prefix = "camel.component.smtps") +@ConfigurationProperties(prefix = "camel.component.mail") public class MailComponentConfiguration { /** http://git-wip-us.apache.org/repos/asf/camel/blob/11469adc/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java index e6e5277..066685d 100644 --- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java +++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java @@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * * Generated by camel-package-maven-plugin - do not edit this file! */ -@ConfigurationProperties(prefix = "camel.component.smpps") +@ConfigurationProperties(prefix = "camel.component.smpp") public class SmppComponentConfiguration { /** http://git-wip-us.apache.org/repos/asf/camel/blob/11469adc/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java index b90c39e..375b1a4 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java @@ -64,6 +64,9 @@ import static org.apache.camel.maven.packaging.PackageHelper.loadText; */ public class SpringBootAutoConfigurationMojo extends AbstractMojo { + private static final String[] SKIP_COMPONENTS = new String[]{"ahc-wss", "cometds", "https", "http4s", "smpps", "solrs", "solrCloud"}; + private static final String[] MAIL_COMPONENTS = new String[]{"imap", "imaps", "pop3", "pop3s", "smtp", "smtps"}; + /** * The maven project. * @@ -120,6 +123,27 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo { if (!componentNames.isEmpty()) { getLog().debug("Found " + componentNames.size() + " components"); for (String componentName : componentNames) { + + // skip some components which is duplicates + boolean skip = false; + for (String name : SKIP_COMPONENTS) { + if (name.equals(componentName)) { + skip = true; + } + } + if (skip) { + continue; + } + + // mail component should just be mail + String overrideComponentName = null; + for (String name : MAIL_COMPONENTS) { + if (name.equals(componentName)) { + overrideComponentName = "mail"; + break; + } + } + String json = loadComponentJson(jsonFiles, componentName); if (json != null) { ComponentModel model = generateComponentModel(componentName, json); @@ -132,7 +156,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo { int pos = model.getJavaType().lastIndexOf("."); String pkg = model.getJavaType().substring(0, pos) + ".springboot"; - createComponentConfigurationSource(pkg, model); + createComponentConfigurationSource(pkg, model, overrideComponentName); createComponentAutoConfigurationSource(pkg, model); createComponentSpringFactorySource(pkg, model); } @@ -174,7 +198,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo { } } - private void createComponentConfigurationSource(String packageName, ComponentModel model) throws MojoFailureException { + private void createComponentConfigurationSource(String packageName, ComponentModel model, String overrideComponentName) throws MojoFailureException { final JavaClassSource javaClass = Roaster.create(JavaClassSource.class); int pos = model.getJavaType().lastIndexOf("."); @@ -188,7 +212,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo { } javaClass.getJavaDoc().setFullText(doc); - String prefix = "camel.component." + model.getScheme(); + String prefix = "camel.component." + (overrideComponentName != null ? overrideComponentName : model.getScheme()); // make sure prefix is in lower case prefix = prefix.toLowerCase(Locale.US); javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix", prefix);