Repository: camel Updated Branches: refs/heads/master cc4e7785f -> 4b0381f29
Added support for excluding generated endpoint config properties by name or type Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4b0381f2 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4b0381f2 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4b0381f2 Branch: refs/heads/master Commit: 4b0381f2983343a4d47a5f3fc3df0ed8427991bc Parents: 37541d2 Author: Dhiraj Bokde <dhira...@yahoo.com> Authored: Wed Jun 11 16:54:04 2014 -0700 Committer: Dhiraj Bokde <dhira...@yahoo.com> Committed: Wed Jun 11 20:10:21 2014 -0700 ---------------------------------------------------------------------- .../maven/AbstractApiMethodGeneratorMojo.java | 28 +++++++++++++++++--- .../maven/JavadocApiMethodGeneratorMojo.java | 6 ++--- .../camel/maven/AbstractGeneratorMojoTest.java | 2 +- .../maven/FileApiMethodGeneratorMojoTest.java | 4 +++ 4 files changed, 33 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/4b0381f2/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java index 852b09e..cba3bb1 100644 --- a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java +++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.regex.Pattern; import org.apache.camel.util.component.ApiMethodParser; import org.apache.camel.util.component.ArgumentSubstitutionParser; @@ -41,15 +42,32 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo @Parameter(property = PREFIX + "substitutions") protected Substitution[] substitutions = new Substitution[0]; + @Parameter(property = PREFIX + "excludeConfigNames") + protected String excludeConfigNames; + + @Parameter(property = PREFIX + "excludeConfigTypes") + protected String excludeConfigTypes; + // cached fields private Class<?> proxyType; + private Pattern propertyNamePattern; + private Pattern propertyTypePattern; + @Override public void execute() throws MojoExecutionException, MojoFailureException { // load proxy class and get enumeration file to generate final Class proxyType = getProxyType(); + // parse pattern for excluded endpoint properties + if (excludeConfigNames != null) { + propertyNamePattern = Pattern.compile(excludeConfigNames); + } + if (excludeConfigTypes != null) { + propertyTypePattern = Pattern.compile(excludeConfigTypes); + } + // create parser ApiMethodParser parser = createAdapterParser(proxyType); parser.setSignatures(getSignatureList()); @@ -137,13 +155,17 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo Map<String, Class<?>> parameters = new TreeMap<String, Class<?>>(); for (ApiMethodParser.ApiMethodModel model : models) { for (ApiMethodParser.Argument argument : model.getArguments()) { - if (!parameters.containsKey(argument.getName())) { - Class<?> type = argument.getType(); + final String name = argument.getName(); + Class<?> type = argument.getType(); + final String typeName = type.getCanonicalName(); + if (!parameters.containsKey(name) && + (propertyNamePattern == null || !propertyNamePattern.matcher(name).matches()) && + (propertyTypePattern == null || !propertyTypePattern.matcher(typeName).matches())) { if (type.isPrimitive()) { // replace primitives with wrapper classes type = ClassUtils.primitiveToWrapper(type); } - parameters.put(argument.getName(), type); + parameters.put(name, type); } } } http://git-wip-us.apache.org/repos/asf/camel/blob/4b0381f2/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java index 28bd958..72116e6 100644 --- a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java +++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java @@ -56,13 +56,13 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj protected static final String DEFAULT_EXCLUDE_PACKAGES = "javax?\\.lang.*"; - @Parameter(property = "camel.component.util.excludePackages", defaultValue = DEFAULT_EXCLUDE_PACKAGES) + @Parameter(property = PREFIX + "excludePackages", defaultValue = DEFAULT_EXCLUDE_PACKAGES) protected String excludePackages; - @Parameter(property = "camel.component.util.excludeClasses") + @Parameter(property = PREFIX + "excludeClasses") protected String excludeClasses; - @Parameter(property = "camel.component.util.excludeMethods") + @Parameter(property = PREFIX + "excludeMethods") protected String excludeMethods; @Override http://git-wip-us.apache.org/repos/asf/camel/blob/4b0381f2/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java index 641b34e..7d67a7b 100644 --- a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java +++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java @@ -29,7 +29,7 @@ import static org.junit.Assert.assertTrue; /** * Base class for Generator MOJO tests. */ -public class AbstractGeneratorMojoTest { +public abstract class AbstractGeneratorMojoTest { protected static final String OUT_DIR = "target/generated-test-sources/camel-component"; private static final String COMPONENT_PACKAGE = "org.apache.camel.component.test"; http://git-wip-us.apache.org/repos/asf/camel/blob/4b0381f2/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java index d77bad7..a68fba8 100644 --- a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java +++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java @@ -48,6 +48,10 @@ public class FileApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest { mojo.proxyClass = TestProxy.class.getCanonicalName(); mojo.signatureFile = new File("src/test/resources/test-proxy-signatures.txt"); + // exclude name2, and int times + mojo.excludeConfigNames = "name2"; + mojo.excludeConfigTypes = "int"; + mojo.execute(); // check target file was generated