You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/01/16 07:25:28 UTC
[camel] branch master updated: Camel-package-maven-plugin: Fixed CS
This is an automated email from the ASF dual-hosted git repository.
acosentino 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 c9c1a87 Camel-package-maven-plugin: Fixed CS
c9c1a87 is described below
commit c9c1a87162bd6faca15d0c909bc680ddc7ff715d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 16 08:24:02 2020 +0100
Camel-package-maven-plugin: Fixed CS
---
.../camel/maven/packaging/EndpointDslMojo.java | 118 ++--
.../packaging/ModelXmlParserGeneratorMojo.java | 609 ++++++++-------------
.../packaging/PackageArchetypeCatalogMojo.java | 11 +-
.../maven/packaging/PackageComponentMojo.java | 23 +-
.../maven/packaging/PackageDataFormatMojo.java | 43 +-
.../camel/maven/packaging/PackageJaxbMojo.java | 41 +-
.../camel/maven/packaging/PackageLanguageMojo.java | 43 +-
.../camel/maven/packaging/PackageLegalMojo.java | 2 +-
.../camel/maven/packaging/PackageModelMojo.java | 10 +-
.../camel/maven/packaging/PackageOtherMojo.java | 26 +-
.../maven/packaging/PrepareCatalogKarafMojo.java | 69 +--
.../camel/maven/packaging/PrepareCatalogMojo.java | 116 ++--
.../maven/packaging/PrepareComponentMojo.java | 28 +-
.../camel/maven/packaging/PrepareExampleMojo.java | 16 +-
.../maven/packaging/PrepareParentPomMojo.java | 4 +-
.../maven/packaging/PrepareReleasePomMojo.java | 7 +-
.../maven/packaging/PrepareUserGuideMojo.java | 7 +-
.../packaging/UpdateDocComponentListMojo.java | 54 +-
.../camel/maven/packaging/UpdateReadmeMojo.java | 53 +-
.../maven/packaging/ValidateComponentMojo.java | 28 +-
.../camel/maven/packaging/ValidateHelper.java | 9 +-
.../maven/packaging/generics/GenericsUtil.java | 6 +-
.../camel/maven/packaging/model/EipModel.java | 1 -
.../maven/packaging/model/EipOptionModel.java | 1 -
.../model/SpringBootAutoConfigureOptionModel.java | 1 -
.../camel/maven/packaging/MvelHelperTest.java | 21 +-
.../maven/packaging/model/StringHelperTest.java | 15 +-
27 files changed, 556 insertions(+), 806 deletions(-)
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
index 0ce9dac..badfdd4 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
@@ -329,7 +329,8 @@ public class EndpointDslMojo extends AbstractMojo {
for (EndpointOptionModel option : model.getEndpointOptions()) {
- // skip all @UriPath parameters as the endpoint DSL is for query parameters
+ // skip all @UriPath parameters as the endpoint DSL is for query
+ // parameters
if ("path".equals(option.getKind())) {
continue;
}
@@ -389,8 +390,10 @@ public class EndpointDslMojo extends AbstractMojo {
desc += "\n";
desc += "\nThe option is a: <code>" + ogtype.toString().replace("<", "<").replace(">", ">") + "</code> type.";
desc += "\n";
- // the Endpoint DSL currently requires to provide the entire context-path and not as individual options
- // so lets only mark query parameters that are required as required
+ // the Endpoint DSL currently requires to provide the entire
+ // context-path and not as individual options
+ // so lets only mark query parameters that are required as
+ // required
if ("parameter".equals(option.getKind()) && "true".equals(option.getRequired())) {
desc += "\nRequired: true";
}
@@ -417,8 +420,10 @@ public class EndpointDslMojo extends AbstractMojo {
desc += "\n";
desc += "\nThe option will be converted to a <code>" + ogtype.toString().replace("<", "<").replace(">", ">") + "</code> type.";
desc += "\n";
- // the Endpoint DSL currently requires to provide the entire context-path and not as individual options
- // so lets only mark query parameters that are required as required
+ // the Endpoint DSL currently requires to provide the
+ // entire context-path and not as individual options
+ // so lets only mark query parameters that are required
+ // as required
if ("parameter".equals(option.getKind()) && "true".equals(option.getRequired())) {
desc += "\nRequired: true";
}
@@ -436,11 +441,11 @@ public class EndpointDslMojo extends AbstractMojo {
javaClass.removeImport("T");
if (aliases.size() == 1) {
- Method method = javaClass.addMethod().setStatic().setName(camelCaseLower(model.getScheme()))
- .addParameter(String.class, "path")
- .setReturnType(new GenericType(loadClass(builderClass.getCanonicalName())))
- .setBody("class " + builderName + "Impl extends AbstractEndpointBuilder implements " + builderName + ", Advanced" + builderName + " {\n" + " public " + builderName
- + "Impl(String path) {\n" + " super(\"" + model.getScheme() + "\", path);\n" + " }\n" + "}\n" + "return new " + builderName + "Impl(path);\n");
+ Method method = javaClass.addMethod().setStatic().setName(camelCaseLower(model.getScheme())).addParameter(String.class, "path")
+ .setReturnType(new GenericType(loadClass(builderClass.getCanonicalName())))
+ .setBody("class " + builderName + "Impl extends AbstractEndpointBuilder implements " + builderName + ", Advanced" + builderName + " {\n" + " public "
+ + builderName + "Impl(String path) {\n" + " super(\"" + model.getScheme() + "\", path);\n" + " }\n" + "}\n" + "return new " + builderName
+ + "Impl(path);\n");
if ("true".equals(model.getDeprecated())) {
method.addAnnotation(Deprecated.class);
@@ -449,10 +454,9 @@ public class EndpointDslMojo extends AbstractMojo {
method.getJavaDoc().setText(desc);
} else {
for (ComponentModel componentModel : aliases) {
- Method method = javaClass.addMethod().setStatic().setName(camelCaseLower(componentModel.getScheme()))
- .addParameter(String.class, "path")
- .setReturnType(new GenericType(loadClass(builderClass.getCanonicalName())))
- .setBody("return " + camelCaseLower(model.getScheme()) + "(\"" + componentModel.getScheme() + "\", path);\n");
+ Method method = javaClass.addMethod().setStatic().setName(camelCaseLower(componentModel.getScheme())).addParameter(String.class, "path")
+ .setReturnType(new GenericType(loadClass(builderClass.getCanonicalName())))
+ .setBody("return " + camelCaseLower(model.getScheme()) + "(\"" + componentModel.getScheme() + "\", path);\n");
if ("true".equals(model.getDeprecated())) {
method.addAnnotation(Deprecated.class);
@@ -460,12 +464,11 @@ public class EndpointDslMojo extends AbstractMojo {
String desc = getMainDescription(componentModel);
method.getJavaDoc().setText(desc);
}
- Method method = javaClass.addMethod().setStatic().setName(camelCaseLower(model.getScheme()))
- .addParameter(String.class, "scheme")
- .addParameter(String.class, "path")
- .setReturnType(new GenericType(loadClass(builderClass.getCanonicalName())))
- .setBody("class " + builderName + "Impl extends AbstractEndpointBuilder implements " + builderName + ", Advanced" + builderName + " {\n" + " public " + builderName
- + "Impl(String scheme, String path) {\n" + " super(scheme, path);\n" + " }\n" + "}\n" + "return new " + builderName + "Impl(scheme, path);\n");
+ Method method = javaClass.addMethod().setStatic().setName(camelCaseLower(model.getScheme())).addParameter(String.class, "scheme").addParameter(String.class, "path")
+ .setReturnType(new GenericType(loadClass(builderClass.getCanonicalName())))
+ .setBody("class " + builderName + "Impl extends AbstractEndpointBuilder implements " + builderName + ", Advanced" + builderName + " {\n" + " public "
+ + builderName + "Impl(String scheme, String path) {\n" + " super(scheme, path);\n" + " }\n" + "}\n" + "return new " + builderName
+ + "Impl(scheme, path);\n");
if ("true".equals(model.getDeprecated())) {
method.addAnnotation(Deprecated.class);
@@ -506,23 +509,15 @@ public class EndpointDslMojo extends AbstractMojo {
MethodDeclaration endpoints = endpointBuilderClass.addMethod("endpoints");
endpoints.setDefault(true);
endpoints.addAndGetParameter("org.apache.camel.builder.EndpointProducerBuilder", "endpoints").setVarArgs(true);
- endpoints.setBody(block(
- "return new org.apache.camel.support.ExpressionAdapter() {",
- " List<org.apache.camel.Expression> expressions = Stream.of(endpoints)",
- " .map(org.apache.camel.builder.EndpointProducerBuilder::expr)",
- " .collect(Collectors.toList());",
- "",
- " @Override",
- " public Object evaluate(org.apache.camel.Exchange exchange) {",
- " return expressions.stream().map(e -> e.evaluate(exchange, Object.class)).collect(Collectors.toList());",
- " }",
- "};")
- );
+ endpoints.setBody(block("return new org.apache.camel.support.ExpressionAdapter() {", " List<org.apache.camel.Expression> expressions = Stream.of(endpoints)",
+ " .map(org.apache.camel.builder.EndpointProducerBuilder::expr)", " .collect(Collectors.toList());", "", " @Override",
+ " public Object evaluate(org.apache.camel.Exchange exchange) {",
+ " return expressions.stream().map(e -> e.evaluate(exchange, Object.class)).collect(Collectors.toList());", " }", "};"));
endpoints.setType("org.apache.camel.Expression");
// Copy entry points from builder factories
- for (File file: allComponentsDslEndpointFactories) {
+ for (File file : allComponentsDslEndpointFactories) {
try {
CompilationUnit unit = StaticJavaParser.parse(file);
Optional<PackageDeclaration> packageDeclaration = unit.getPackageDeclaration();
@@ -535,7 +530,7 @@ public class EndpointDslMojo extends AbstractMojo {
ClassOrInterfaceDeclaration type = typeDeclaration.get().asClassOrInterfaceDeclaration();
- for (MethodDeclaration declaration: type.getMethods()) {
+ for (MethodDeclaration declaration : type.getMethods()) {
if (declaration.isStatic()) {
MethodDeclaration method = endpointBuilderClass.addMethod(declaration.getNameAsString());
method.setDefault(true);
@@ -544,23 +539,10 @@ public class EndpointDslMojo extends AbstractMojo {
// copy annotations from the source method
declaration.getAnnotations().forEach(method::addAnnotation);
- method.setBody(
- new BlockStmt().addStatement(
- String.format("return %s.%s.%s(%s);",
- packageDeclaration.get().getNameAsString(),
- type.getNameAsString(),
- declaration.getNameAsString(),
- declaration.getParameters().stream().map(p -> p.getNameAsString()).collect(Collectors.joining(", "))
- )
- )
- );
- method.setType(
- String.format("%s.%s.%s",
- packageDeclaration.get().getNameAsString(),
- type.getNameAsString(),
- declaration.getType()
- )
- );
+ method.setBody(new BlockStmt()
+ .addStatement(String.format("return %s.%s.%s(%s);", packageDeclaration.get().getNameAsString(), type.getNameAsString(), declaration.getNameAsString(),
+ declaration.getParameters().stream().map(p -> p.getNameAsString()).collect(Collectors.joining(", ")))));
+ method.setType(String.format("%s.%s.%s", packageDeclaration.get().getNameAsString(), type.getNameAsString(), declaration.getType()));
declaration.getJavadoc().ifPresent(method::setJavadocComment);
}
@@ -570,7 +552,6 @@ public class EndpointDslMojo extends AbstractMojo {
}
}
-
endpointBuilderUnit.addOrphanComment(new LineComment("CHECKSTYLE:ON"));
writeSourceIfChanged(endpointBuilderUnit.toString(), interfaceFactoryPath);
}
@@ -592,7 +573,7 @@ public class EndpointDslMojo extends AbstractMojo {
endpointBuilderClass.addSingleMemberAnnotation("javax.annotation.Generated", "\"" + EndpointDslMojo.class.getName() + "\"");
// Copy entry points from builder factories
- for (File file: allComponentsDslEndpointFactories) {
+ for (File file : allComponentsDslEndpointFactories) {
try {
CompilationUnit unit = StaticJavaParser.parse(file);
Optional<PackageDeclaration> packageDeclaration = unit.getPackageDeclaration();
@@ -605,7 +586,7 @@ public class EndpointDslMojo extends AbstractMojo {
ClassOrInterfaceDeclaration type = typeDeclaration.get().asClassOrInterfaceDeclaration();
- for (MethodDeclaration declaration: type.getMethods()) {
+ for (MethodDeclaration declaration : type.getMethods()) {
if (declaration.isStatic()) {
MethodDeclaration method = endpointBuilderClass.addMethod(declaration.getNameAsString());
method.setStatic(true);
@@ -614,23 +595,10 @@ public class EndpointDslMojo extends AbstractMojo {
// copy annotations from the source method
declaration.getAnnotations().forEach(method::addAnnotation);
- method.setBody(
- new BlockStmt().addStatement(
- String.format("return %s.%s.%s(%s);",
- packageDeclaration.get().getNameAsString(),
- type.getNameAsString(),
- declaration.getNameAsString(),
- declaration.getParameters().stream().map(p -> p.getNameAsString()).collect(Collectors.joining(", "))
- )
- )
- );
- method.setType(
- String.format("%s.%s.%s",
- packageDeclaration.get().getNameAsString(),
- type.getNameAsString(),
- declaration.getType()
- )
- );
+ method.setBody(new BlockStmt()
+ .addStatement(String.format("return %s.%s.%s(%s);", packageDeclaration.get().getNameAsString(), type.getNameAsString(), declaration.getNameAsString(),
+ declaration.getParameters().stream().map(p -> p.getNameAsString()).collect(Collectors.joining(", ")))));
+ method.setType(String.format("%s.%s.%s", packageDeclaration.get().getNameAsString(), type.getNameAsString(), declaration.getType()));
declaration.getJavadoc().ifPresent(method::setJavadocComment);
}
@@ -649,9 +617,7 @@ public class EndpointDslMojo extends AbstractMojo {
final File allComponentsDslEndpointFactory = new File(outputDir, packageName.replace('.', '/'));
// load components
- return Arrays.asList(allComponentsDslEndpointFactory.listFiles()).stream()
- .filter(file -> file.isFile() && file.getName().endsWith(".java") && file.exists())
- .sorted()
+ return Arrays.asList(allComponentsDslEndpointFactory.listFiles()).stream().filter(file -> file.isFile() && file.getName().endsWith(".java") && file.exists()).sorted()
.collect(Collectors.toList());
}
@@ -1045,8 +1011,6 @@ public class EndpointDslMojo extends AbstractMojo {
}
private static BlockStmt block(String... statements) {
- return StaticJavaParser.parseBlock(
- "{" + Stream.of(statements).collect(Collectors.joining("\n")) + "}"
- );
+ return StaticJavaParser.parseBlock("{" + Stream.of(statements).collect(Collectors.joining("\n")) + "}");
}
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlParserGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlParserGeneratorMojo.java
index ad58c9b..9956a49 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlParserGeneratorMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlParserGeneratorMojo.java
@@ -115,54 +115,25 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
expressionDefinitionClass = loadClass(classLoader, MODEL_PACKAGE + ".language.ExpressionDefinition");
String resName = routesDefinitionClass.getName().replace('.', '/') + ".class";
- String url = classLoader.getResource(resName).toExternalForm()
- .replace(resName, "META-INF/jandex.idx");
+ String url = classLoader.getResource(resName).toExternalForm().replace(resName, "META-INF/jandex.idx");
Index index;
try (InputStream is = new URL(url).openStream()) {
index = new IndexReader(is).read();
} catch (IOException e) {
throw new MojoExecutionException("IOException: " + e.getMessage(), e);
}
- List<Class<?>> model = Stream.of(XmlRootElement.class, XmlEnum.class, XmlType.class)
- .map(Class::getName)
- .map(DotName::createSimple)
- .map(index::getAnnotations)
- .flatMap(Collection::stream)
- .map(AnnotationInstance::target)
- .map(AnnotationTarget::asClass)
- .map(ClassInfo::name)
- .map(DotName::toString)
- .sorted()
- .distinct()
- .map(name -> loadClass(classLoader, name))
- .flatMap(this::references)
- .flatMap(this::fieldReferences)
- .distinct()
- .collect(Collectors.toList());
+ List<Class<?>> model = Stream.of(XmlRootElement.class, XmlEnum.class, XmlType.class).map(Class::getName).map(DotName::createSimple).map(index::getAnnotations)
+ .flatMap(Collection::stream).map(AnnotationInstance::target).map(AnnotationTarget::asClass).map(ClassInfo::name).map(DotName::toString).sorted().distinct()
+ .map(name -> loadClass(classLoader, name)).flatMap(this::references).flatMap(this::fieldReferences).distinct().collect(Collectors.toList());
JavaClass parser = generateParser(model, classLoader);
- return "/*\n"
- + " * Licensed to the Apache Software Foundation (ASF) under one or more\n"
- + " * contributor license agreements. See the NOTICE file distributed with\n"
- + " * this work for additional information regarding copyright ownership.\n"
- + " * The ASF licenses this file to You under the Apache License, Version 2.0\n"
- + " * (the \"License\"); you may not use this file except in compliance with\n"
- + " * the License. You may obtain a copy of the License at\n"
- + " *\n"
- + " * http://www.apache.org/licenses/LICENSE-2.0\n"
- + " *\n"
- + " * Unless required by applicable law or agreed to in writing, software\n"
- + " * distributed under the License is distributed on an \"AS IS\" BASIS,\n"
- + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
- + " * See the License for the specific language governing permissions and\n"
- + " * limitations under the License.\n"
- + " */\n"
- + "\n"
- + "//CHECKSTYLE:OFF\n"
- + "\n"
- + parser.printClass()
- + "\n"
- + "//CHECKSTYLE:ON\n";
+ return "/*\n" + " * Licensed to the Apache Software Foundation (ASF) under one or more\n" + " * contributor license agreements. See the NOTICE file distributed with\n"
+ + " * this work for additional information regarding copyright ownership.\n" + " * The ASF licenses this file to You under the Apache License, Version 2.0\n"
+ + " * (the \"License\"); you may not use this file except in compliance with\n" + " * the License. You may obtain a copy of the License at\n" + " *\n"
+ + " * http://www.apache.org/licenses/LICENSE-2.0\n" + " *\n" + " * Unless required by applicable law or agreed to in writing, software\n"
+ + " * distributed under the License is distributed on an \"AS IS\" BASIS,\n" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
+ + " * See the License for the specific language governing permissions and\n" + " * limitations under the License.\n" + " */\n" + "\n" + "//CHECKSTYLE:OFF\n" + "\n"
+ + parser.printClass() + "\n" + "//CHECKSTYLE:ON\n";
}
protected Class<?> loadClass(ClassLoader loader, String name) {
@@ -180,27 +151,20 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
}
return allClasses.stream();
}
+
private Stream<Class<?>> fieldReferences(Class<?> clazz) {
- return Stream.concat(
- Stream.of(clazz),
- Stream.of(clazz.getDeclaredFields())
- .filter(f -> f.getAnnotation(XmlTransient.class) == null)
- .map(f -> {
- if (f.getAnnotation(XmlJavaTypeAdapter.class) != null) {
- Class<?> cl = f.getAnnotation(XmlJavaTypeAdapter.class).value();
- while (cl.getSuperclass() != XmlAdapter.class) {
- cl = cl.getSuperclass();
- }
- return ((ParameterizedType) cl.getGenericSuperclass()).getActualTypeArguments()[0];
- } else {
- return f.getGenericType();
- }
- })
- .map(GenericType::new)
- .map(t -> t.getRawClass() == List.class ? t.getActualTypeArgument(0) : t)
- .map(GenericType::getRawClass)
- .filter(c -> c.getName().startsWith("org.apache.camel."))
- );
+ return Stream.concat(Stream.of(clazz), Stream.of(clazz.getDeclaredFields()).filter(f -> f.getAnnotation(XmlTransient.class) == null).map(f -> {
+ if (f.getAnnotation(XmlJavaTypeAdapter.class) != null) {
+ Class<?> cl = f.getAnnotation(XmlJavaTypeAdapter.class).value();
+ while (cl.getSuperclass() != XmlAdapter.class) {
+ cl = cl.getSuperclass();
+ }
+ return ((ParameterizedType)cl.getGenericSuperclass()).getActualTypeArguments()[0];
+ } else {
+ return f.getGenericType();
+ }
+ }).map(GenericType::new).map(t -> t.getRawClass() == List.class ? t.getActualTypeArgument(0) : t).map(GenericType::getRawClass)
+ .filter(c -> c.getName().startsWith("org.apache.camel.")));
}
// CHECKSTYLE:OFF
@@ -216,46 +180,16 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
parser.addImport(Array.class);
parser.addAnnotation(SuppressWarnings.class).setLiteralValue("\"unused\"");
parser.addAnnotation(Generated.class).setLiteralValue("\"" + getClass().getName() + "\"");
- parser.addMethod()
- .setConstructor(true)
- .setPublic()
- .setName("ModelParser")
- .addParameter(InputStream.class, "input")
- .addThrows(IOException.class)
- .addThrows(XML_PULL_PARSER_EXCEPTION)
- .setBody("super(input);");
- parser.addMethod()
- .setConstructor(true)
- .setPublic()
- .setName("ModelParser")
- .addParameter(Reader.class, "reader")
- .addThrows(IOException.class)
- .addThrows(XML_PULL_PARSER_EXCEPTION)
- .setBody("super(reader);");
- parser.addMethod()
- .setConstructor(true)
- .setPublic()
- .setName("ModelParser")
- .addParameter(InputStream.class, "input")
- .addParameter(String.class, "namespace")
- .addThrows(IOException.class)
- .addThrows(XML_PULL_PARSER_EXCEPTION)
- .setBody("super(input, namespace);");
- parser.addMethod()
- .setConstructor(true)
- .setPublic()
- .setName("ModelParser")
- .addParameter(Reader.class, "reader")
- .addParameter(String.class, "namespace")
- .addThrows(IOException.class)
- .addThrows(XML_PULL_PARSER_EXCEPTION)
- .setBody("super(reader, namespace);");
-
- List<Class<?>> elementRefs = Arrays.asList(
- processorDefinitionClass,
- expressionDefinitionClass,
- dataFormatDefinitionClass
- );
+ parser.addMethod().setConstructor(true).setPublic().setName("ModelParser").addParameter(InputStream.class, "input").addThrows(IOException.class)
+ .addThrows(XML_PULL_PARSER_EXCEPTION).setBody("super(input);");
+ parser.addMethod().setConstructor(true).setPublic().setName("ModelParser").addParameter(Reader.class, "reader").addThrows(IOException.class)
+ .addThrows(XML_PULL_PARSER_EXCEPTION).setBody("super(reader);");
+ parser.addMethod().setConstructor(true).setPublic().setName("ModelParser").addParameter(InputStream.class, "input").addParameter(String.class, "namespace")
+ .addThrows(IOException.class).addThrows(XML_PULL_PARSER_EXCEPTION).setBody("super(input, namespace);");
+ parser.addMethod().setConstructor(true).setPublic().setName("ModelParser").addParameter(Reader.class, "reader").addParameter(String.class, "namespace")
+ .addThrows(IOException.class).addThrows(XML_PULL_PARSER_EXCEPTION).setBody("super(reader, namespace);");
+
+ List<Class<?>> elementRefs = Arrays.asList(processorDefinitionClass, expressionDefinitionClass, dataFormatDefinitionClass);
for (Class<?> clazz : model) {
if (clazz.getAnnotation(XmlEnum.class) != null || clazz.isInterface()) {
@@ -275,13 +209,10 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
List<Member> members = getMembers(clazz);
// XmlAttribute
- List<Member> attributeMembers = members.stream()
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlAttribute.class) != null)
- .collect(Collectors.toList());
+ List<Member> attributeMembers = members.stream().filter(member -> ((AccessibleObject)member).getAnnotation(XmlAttribute.class) != null).collect(Collectors.toList());
String baseAttributeHandler = null;
for (Class<?> parent = clazz.getSuperclass(); parent != Object.class; parent = parent.getSuperclass()) {
- if (getMembers(parent).stream()
- .anyMatch(member -> ((AccessibleObject) member).getAnnotation(XmlAttribute.class) != null)) {
+ if (getMembers(parent).stream().anyMatch(member -> ((AccessibleObject)member).getAnnotation(XmlAttribute.class) != null)) {
baseAttributeHandler = lowercase(parent.getSimpleName()) + "AttributeHandler()";
break;
}
@@ -292,10 +223,10 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
} else {
SortedMap<String, String> cases = new TreeMap<>();
for (Member member : attributeMembers) {
- Type pt = member instanceof Method ? ((Method) member).getGenericParameterTypes()[0] : ((Field) member).getGenericType();
+ Type pt = member instanceof Method ? ((Method)member).getGenericParameterTypes()[0] : ((Field)member).getGenericType();
GenericType type = new GenericType(pt);
String mn = member.getName();
- String an = ((AccessibleObject) member).getAnnotation(XmlAttribute.class).name();
+ String an = ((AccessibleObject)member).getAnnotation(XmlAttribute.class).name();
if ("##default".equals(an)) {
an = member instanceof Method ? propname(mn) : mn;
}
@@ -305,186 +236,150 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
String defaultCase = baseAttributeHandler != null ? baseAttributeHandler + ".accept(def, key, val)" : "false";
if (attributeMembers.size() == 1) {
Map.Entry<String, String> entry = cases.entrySet().iterator().next();
- attributes =
- " (def, key, val) -> {\n" +
- " if (\"" + entry.getKey() + "\".equals(key)) {\n" +
- " " + entry.getValue() + "\n" +
- " return true;\n" +
- " }\n" +
- " return " + defaultCase + ";\n" +
- "}";
+ attributes = " (def, key, val) -> {\n" + " if (\"" + entry.getKey() + "\".equals(key)) {\n" + " " + entry.getValue() + "\n" + " return true;\n"
+ + " }\n" + " return " + defaultCase + ";\n" + "}";
} else {
StringBuilder sb = new StringBuilder();
- sb.append(" (def, key, val) -> {\n"
- + " switch (key) {\n");
+ sb.append(" (def, key, val) -> {\n" + " switch (key) {\n");
for (Map.Entry<String, String> entry : cases.entrySet()) {
sb.append(" case \"").append(entry.getKey()).append("\": ").append(entry.getValue()).append(" break;\n");
}
- sb.append(" default: return ").append(defaultCase).append(";\n"
- + " }\n"
- + " return true;\n"
- + "}");
+ sb.append(" default: return ").append(defaultCase).append(";\n" + " }\n" + " return true;\n" + "}");
attributes = sb.toString();
}
}
// @XmlAnyAttribute
- members.stream()
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlAnyAttribute.class) != null)
- .forEach(member -> {
- if (!"otherAttributes".equals(member.getName())) {
- throw new UnsupportedOperationException("Class " + clazz.getName() + " / member " + member + ": unsupported @XmlAnyAttribute");
- }
- });
-
+ members.stream().filter(member -> ((AccessibleObject)member).getAnnotation(XmlAnyAttribute.class) != null).forEach(member -> {
+ if (!"otherAttributes".equals(member.getName())) {
+ throw new UnsupportedOperationException("Class " + clazz.getName() + " / member " + member + ": unsupported @XmlAnyAttribute");
+ }
+ });
// @XmlElementRef @XmlElement @XmlElements
- List<Member> elementMembers = members.stream()
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlAttribute.class) == null)
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlAnyAttribute.class) == null)
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlValue.class) == null)
- .collect(Collectors.toList());
+ List<Member> elementMembers = members.stream().filter(member -> ((AccessibleObject)member).getAnnotation(XmlAttribute.class) == null)
+ .filter(member -> ((AccessibleObject)member).getAnnotation(XmlAnyAttribute.class) == null)
+ .filter(member -> ((AccessibleObject)member).getAnnotation(XmlValue.class) == null).collect(Collectors.toList());
List<Member> multiElements = members.stream()
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlElementRef.class) != null
- || ((AccessibleObject) member).getAnnotation(XmlElements.class) != null
- || (clazz == outputDefinitionClass && "setOutputs".equals(member.getName())))
- .collect(Collectors.toList());
+ .filter(member -> ((AccessibleObject)member).getAnnotation(XmlElementRef.class) != null || ((AccessibleObject)member).getAnnotation(XmlElements.class) != null
+ || (clazz == outputDefinitionClass && "setOutputs".equals(member.getName())))
+ .collect(Collectors.toList());
Map<String, String> expressionHandlersDefs = new LinkedHashMap<>();
Map<String, String> cases = new LinkedHashMap<>();
// XmlElementRef
- elementMembers.stream()
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlElementRef.class) != null
- || (clazz == outputDefinitionClass && "setOutputs".equals(member.getName())))
- .forEach(member -> {
- Type pt = member instanceof Method ? ((Method) member).getGenericParameterTypes()[0] : ((Field) member).getGenericType();
- GenericType type = new GenericType(pt);
- boolean list = type.getRawClass() == List.class;
- String fn = member.getName();
- String sn = member instanceof Method ? fn : "set" + uppercase(fn);
- String gn = member instanceof Method ? "g" + sn.substring(1) : "get" + uppercase(fn);
- Class<?> root = list ? type.getActualTypeArgument(0).getRawClass() : type.getRawClass();
- if (elementRefs.contains(root)) {
- expressionHandlersDefs.put(lowercase(sn.substring(3)),
- " " + root.getSimpleName() + " v = doParse" + root.getSimpleName() + "Ref(key);\n" +
- " if (v != null) { \n" +
- " " + (list ? "doAdd(v, def." + gn + "(), def::" + sn + ");" : "def." + sn + "(v);") + "\n" +
- " return true;\n" +
- " }\n");
- } else {
- model.stream()
- .filter(root::isAssignableFrom)
- .filter(cl -> cl.getAnnotation(XmlRootElement.class) != null)
- .forEach(cl -> {
- String en = cl.getAnnotation(XmlRootElement.class).name();
- if ("##default".equals(en)) {
- en = lowercase(cl.getSimpleName());
- }
- String tn = cl.getSimpleName();
- cases.put(en, list
- ? "doAdd(doParse" + tn + "(), def." + gn + "(), def::" + sn + ");"
- : "def." + sn + "(doParse" + tn + "());");
- });
- }
- });
- // @XmlElements
- elementMembers.stream()
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlElements.class) != null)
- .forEach(member -> {
- Type pt = member instanceof Method ? ((Method) member).getGenericParameterTypes()[0] : ((Field) member).getGenericType();
- GenericType type = new GenericType(pt);
- boolean list = type.getRawClass() == List.class;
- String fn = member.getName();
- String sn = member instanceof Method ? fn : "set" + uppercase(fn);
- String gn = member instanceof Method ? "g" + sn.substring(1) : "get" + uppercase(fn);
- Class<?> root = list ? type.getActualTypeArgument(0).getRawClass() : type.getRawClass();
- if (elementRefs.contains(root)) {
- expressionHandlersDefs.put(lowercase(sn.substring(3)),
- " " + root.getSimpleName() + " v = doParse" + root.getSimpleName() + "Ref(key);\n" +
- " if (v != null) { \n" +
- " " + (list ? "doAdd(v, def." + gn + "(), def::" + sn + ");" : "def." + sn + "(v);") + "\n" +
- " return true;\n" +
- " }\n");
- } else {
- Stream.of(((AccessibleObject) member).getAnnotation(XmlElements.class).value()).forEach(xe -> {
- String en = xe.name();
- String tn = xe.type().getSimpleName();
- cases.put(en, list
- ? "doAdd(doParse" + tn + "(), def." + gn + "(), def::" + sn + ");"
- : "def." + sn + "(doParse" + tn + "());");
- });
- }
- });
- elementMembers.stream()
- .filter(member -> !multiElements.contains(member))
- .forEach(member -> {
- Type pt = member instanceof Method ? ((Method) member).getGenericParameterTypes()[0] : ((Field) member).getGenericType();
- GenericType type = new GenericType(pt);
- boolean list;
- Class<?> root;
- if (type.getRawClass() == List.class) {
- list = true;
- root = type.getActualTypeArgument(0).getRawClass();
- } else if (type.getRawClass().isArray()) {
- list = true;
- root = type.getRawClass().getComponentType();
- } else {
- list = false;
- root = type.getRawClass();
- }
- String fn = member.getName();
- String en = "##default";
- if (((AccessibleObject) member).getAnnotation(XmlElement.class) != null) {
- en = ((AccessibleObject) member).getAnnotation(XmlElement.class).name();
- }
- if ("##default".equals(en)) {
- en = member instanceof Method ? propname(fn) : fn;
- }
- String sn = member instanceof Method ? fn : "set" + uppercase(fn);
- String gn = member instanceof Method ? "g" + sn.substring(1) : "get" + uppercase(fn);
- String tn = root.getSimpleName();
- String pc;
- if (((AccessibleObject) member).getAnnotation(XmlJavaTypeAdapter.class) != null) {
- Class<? extends XmlAdapter> adapter = ((AccessibleObject) member).getAnnotation(XmlJavaTypeAdapter.class).value();
- Class<?> cl = adapter;
- while (cl.getSuperclass() != XmlAdapter.class) {
- cl = cl.getSuperclass();
- }
- Type t = ((ParameterizedType) cl.getGenericSuperclass()).getActualTypeArguments()[0];
- Class<?> c = new GenericType(t).getRawClass();
- String n = adapter.getDeclaringClass() != null
- ? adapter.getDeclaringClass().getSimpleName() + "." + adapter.getSimpleName()
- : adapter.getSimpleName();
- if (c == String.class) {
- pc = "unmarshal(new " + n + "(), doParseText())";
- } else if (model.contains(c)) {
- pc = "unmarshal(new " + n + "(), doParse" + c.getSimpleName() + "())";
- } else{
- throw new UnsupportedOperationException("Class " + clazz.getName() + " / member " + member + ": unsupported @XmlJavaTypeAdapter");
- }
- if (list && type.equals(new GenericType(((ParameterizedType) cl.getGenericSuperclass()).getActualTypeArguments()[1]))) {
- list = false;
- }
- } else if (model.contains(root)) {
- pc = "doParse" + tn + "()";
- } else if (root == String.class) {
- pc = "doParseText()";
- } else {
- String n = root.getName();
- if (n.startsWith("java.lang.")) {
- n = tn;
+ elementMembers.stream().filter(member -> ((AccessibleObject)member).getAnnotation(XmlElementRef.class) != null
+ || (clazz == outputDefinitionClass && "setOutputs".equals(member.getName())))
+ .forEach(member -> {
+ Type pt = member instanceof Method ? ((Method)member).getGenericParameterTypes()[0] : ((Field)member).getGenericType();
+ GenericType type = new GenericType(pt);
+ boolean list = type.getRawClass() == List.class;
+ String fn = member.getName();
+ String sn = member instanceof Method ? fn : "set" + uppercase(fn);
+ String gn = member instanceof Method ? "g" + sn.substring(1) : "get" + uppercase(fn);
+ Class<?> root = list ? type.getActualTypeArgument(0).getRawClass() : type.getRawClass();
+ if (elementRefs.contains(root)) {
+ expressionHandlersDefs.put(lowercase(sn.substring(3)),
+ " " + root.getSimpleName() + " v = doParse" + root.getSimpleName() + "Ref(key);\n" + " if (v != null) { \n" + " "
+ + (list ? "doAdd(v, def." + gn + "(), def::" + sn + ");" : "def." + sn + "(v);") + "\n"
+ + " return true;\n" + " }\n");
+ } else {
+ model.stream().filter(root::isAssignableFrom).filter(cl -> cl.getAnnotation(XmlRootElement.class) != null).forEach(cl -> {
+ String en = cl.getAnnotation(XmlRootElement.class).name();
+ if ("##default".equals(en)) {
+ en = lowercase(cl.getSimpleName());
}
- pc = n + ".valueOf(doParseText())";
- }
- cases.put(en, list
- ? "doAdd(" + pc + ", def." + gn + "(), def::" + sn + ");"
- : "def." + sn + "(" + pc + ");");
+ String tn = cl.getSimpleName();
+ cases.put(en, list ? "doAdd(doParse" + tn + "(), def." + gn + "(), def::" + sn + ");" : "def." + sn + "(doParse" + tn + "());");
+ });
+ }
+ });
+ // @XmlElements
+ elementMembers.stream().filter(member -> ((AccessibleObject)member).getAnnotation(XmlElements.class) != null).forEach(member -> {
+ Type pt = member instanceof Method ? ((Method)member).getGenericParameterTypes()[0] : ((Field)member).getGenericType();
+ GenericType type = new GenericType(pt);
+ boolean list = type.getRawClass() == List.class;
+ String fn = member.getName();
+ String sn = member instanceof Method ? fn : "set" + uppercase(fn);
+ String gn = member instanceof Method ? "g" + sn.substring(1) : "get" + uppercase(fn);
+ Class<?> root = list ? type.getActualTypeArgument(0).getRawClass() : type.getRawClass();
+ if (elementRefs.contains(root)) {
+ expressionHandlersDefs.put(lowercase(sn.substring(3)),
+ " " + root.getSimpleName() + " v = doParse" + root.getSimpleName() + "Ref(key);\n" + " if (v != null) { \n" + " "
+ + (list ? "doAdd(v, def." + gn + "(), def::" + sn + ");" : "def." + sn + "(v);") + "\n"
+ + " return true;\n" + " }\n");
+ } else {
+ Stream.of(((AccessibleObject)member).getAnnotation(XmlElements.class).value()).forEach(xe -> {
+ String en = xe.name();
+ String tn = xe.type().getSimpleName();
+ cases.put(en, list ? "doAdd(doParse" + tn + "(), def." + gn + "(), def::" + sn + ");" : "def." + sn + "(doParse" + tn + "());");
});
+ }
+ });
+ elementMembers.stream().filter(member -> !multiElements.contains(member)).forEach(member -> {
+ Type pt = member instanceof Method ? ((Method)member).getGenericParameterTypes()[0] : ((Field)member).getGenericType();
+ GenericType type = new GenericType(pt);
+ boolean list;
+ Class<?> root;
+ if (type.getRawClass() == List.class) {
+ list = true;
+ root = type.getActualTypeArgument(0).getRawClass();
+ } else if (type.getRawClass().isArray()) {
+ list = true;
+ root = type.getRawClass().getComponentType();
+ } else {
+ list = false;
+ root = type.getRawClass();
+ }
+ String fn = member.getName();
+ String en = "##default";
+ if (((AccessibleObject)member).getAnnotation(XmlElement.class) != null) {
+ en = ((AccessibleObject)member).getAnnotation(XmlElement.class).name();
+ }
+ if ("##default".equals(en)) {
+ en = member instanceof Method ? propname(fn) : fn;
+ }
+ String sn = member instanceof Method ? fn : "set" + uppercase(fn);
+ String gn = member instanceof Method ? "g" + sn.substring(1) : "get" + uppercase(fn);
+ String tn = root.getSimpleName();
+ String pc;
+ if (((AccessibleObject)member).getAnnotation(XmlJavaTypeAdapter.class) != null) {
+ Class<? extends XmlAdapter> adapter = ((AccessibleObject)member).getAnnotation(XmlJavaTypeAdapter.class).value();
+ Class<?> cl = adapter;
+ while (cl.getSuperclass() != XmlAdapter.class) {
+ cl = cl.getSuperclass();
+ }
+ Type t = ((ParameterizedType)cl.getGenericSuperclass()).getActualTypeArguments()[0];
+ Class<?> c = new GenericType(t).getRawClass();
+ String n = adapter.getDeclaringClass() != null ? adapter.getDeclaringClass().getSimpleName() + "." + adapter.getSimpleName() : adapter.getSimpleName();
+ if (c == String.class) {
+ pc = "unmarshal(new " + n + "(), doParseText())";
+ } else if (model.contains(c)) {
+ pc = "unmarshal(new " + n + "(), doParse" + c.getSimpleName() + "())";
+ } else {
+ throw new UnsupportedOperationException("Class " + clazz.getName() + " / member " + member + ": unsupported @XmlJavaTypeAdapter");
+ }
+ if (list && type.equals(new GenericType(((ParameterizedType)cl.getGenericSuperclass()).getActualTypeArguments()[1]))) {
+ list = false;
+ }
+ } else if (model.contains(root)) {
+ pc = "doParse" + tn + "()";
+ } else if (root == String.class) {
+ pc = "doParseText()";
+ } else {
+ String n = root.getName();
+ if (n.startsWith("java.lang.")) {
+ n = tn;
+ }
+ pc = n + ".valueOf(doParseText())";
+ }
+ cases.put(en, list ? "doAdd(" + pc + ", def." + gn + "(), def::" + sn + ");" : "def." + sn + "(" + pc + ");");
+ });
String expressionHandler = null;
for (Class<?> parent = clazz.getSuperclass(); parent != Object.class; parent = parent.getSuperclass()) {
if (getMembers(parent).stream()
- .anyMatch(member -> ((AccessibleObject) member).getAnnotation(XmlAttribute.class) == null
- && ((AccessibleObject) member).getAnnotation(XmlAnyAttribute.class) == null
- && ((AccessibleObject) member).getAnnotation(XmlValue.class) == null)) {
+ .anyMatch(member -> ((AccessibleObject)member).getAnnotation(XmlAttribute.class) == null
+ && ((AccessibleObject)member).getAnnotation(XmlAnyAttribute.class) == null
+ && ((AccessibleObject)member).getAnnotation(XmlValue.class) == null)) {
expressionHandler = lowercase(parent.getSimpleName()) + "ElementHandler()";
break;
}
@@ -497,129 +392,87 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
if (expressionHandlersDefs.isEmpty()) {
elements = (expressionHandler == null ? " noElementHandler()" : " " + expressionHandler);
} else {
- elements = " (def, key) -> {\n" + expressionHandlersDefs.values().iterator().next() +
- " return " + (expressionHandler == null
- ? "false" : expressionHandler + ".accept(def, key)") + ";\n" +
- "}";
+ elements = " (def, key) -> {\n" + expressionHandlersDefs.values().iterator().next() + " return "
+ + (expressionHandler == null ? "false" : expressionHandler + ".accept(def, key)") + ";\n" + "}";
}
} else {
- String returnClause = (expressionHandlersDefs.isEmpty()
- ? "" : expressionHandlersDefs.values().iterator().next() + " ") +
- (expressionHandler == null
- ? "return false;" : "return " + expressionHandler + ".accept(def, key);");
+ String returnClause = (expressionHandlersDefs.isEmpty() ? "" : expressionHandlersDefs.values().iterator().next() + " ")
+ + (expressionHandler == null ? "return false;" : "return " + expressionHandler + ".accept(def, key);");
if (cases.size() == 1) {
Map.Entry<String, String> entry = cases.entrySet().iterator().next();
- elements =
- " (def, key) -> {\n" +
- " if (\"" + entry.getKey() + "\".equals(key)) {\n" +
- " " + entry.getValue() + "\n" +
- " return true;\n" +
- " }\n" +
- " " + returnClause + "\n" +
- "}";
+ elements = " (def, key) -> {\n" + " if (\"" + entry.getKey() + "\".equals(key)) {\n" + " " + entry.getValue() + "\n" + " return true;\n"
+ + " }\n" + " " + returnClause + "\n" + "}";
} else {
StringBuilder sb = new StringBuilder();
- sb.append(" (def, key) -> {\n" +
- " switch (key) {\n");
+ sb.append(" (def, key) -> {\n" + " switch (key) {\n");
for (Map.Entry<String, String> entry : cases.entrySet()) {
- sb.append(" case \"")
- .append(entry.getKey())
- .append("\": ")
- .append(entry.getValue())
- .append(" break;\n");
+ sb.append(" case \"").append(entry.getKey()).append("\": ").append(entry.getValue()).append(" break;\n");
}
sb.append(" default: ");
if (expressionHandlersDefs.isEmpty()) {
sb.append(returnClause);
} else {
- Stream.of(returnClause.split("\n"))
- .forEach(s -> sb.append("\n ").append(s));
+ Stream.of(returnClause.split("\n")).forEach(s -> sb.append("\n ").append(s));
}
sb.append("\n");
- sb.append(" }\n" +
- " return true;\n" +
- "}");
+ sb.append(" }\n" + " return true;\n" + "}");
elements = sb.toString();
}
}
// @XmlValue
- String value = members.stream()
- .filter(member -> ((AccessibleObject) member).getAnnotation(XmlValue.class) != null)
- .findFirst()
- .map(member -> {
- String fn = member.getName();
- String sn = member instanceof Method ? fn : "set" + uppercase(fn);
- if (expressionDefinitionClass.isAssignableFrom(member.getDeclaringClass())) {
- return " expressionDefinitionValueHandler()";
- } else {
- return " (def, val) -> def." + sn + "(val)";
- }
- })
- .orElseGet(() -> {
- for (Class<?> parent = clazz.getSuperclass(); parent != Object.class; parent = parent.getSuperclass()) {
- if (getMembers(parent).stream()
- .anyMatch(member -> ((AccessibleObject) member).getAnnotation(XmlValue.class) != null)) {
- return " " + lowercase(parent.getSimpleName()) + "ValueHandler()";
- }
- }
- return " noValueHandler()";
- });
+ String value = members.stream().filter(member -> ((AccessibleObject)member).getAnnotation(XmlValue.class) != null).findFirst().map(member -> {
+ String fn = member.getName();
+ String sn = member instanceof Method ? fn : "set" + uppercase(fn);
+ if (expressionDefinitionClass.isAssignableFrom(member.getDeclaringClass())) {
+ return " expressionDefinitionValueHandler()";
+ } else {
+ return " (def, val) -> def." + sn + "(val)";
+ }
+ }).orElseGet(() -> {
+ for (Class<?> parent = clazz.getSuperclass(); parent != Object.class; parent = parent.getSuperclass()) {
+ if (getMembers(parent).stream().anyMatch(member -> ((AccessibleObject)member).getAnnotation(XmlValue.class) != null)) {
+ return " " + lowercase(parent.getSimpleName()) + "ValueHandler()";
+ }
+ }
+ return " noValueHandler()";
+ });
if (clazz == routesDefinitionClass || clazz == restsDefinitionClass) {
String element = clazz.getAnnotation(XmlRootElement.class).name();
- parser.addMethod()
- .setPublic()
- .setReturnType(clazz)
- .setName("parse" + name)
- .addThrows(IOException.class)
- .addThrows(XML_PULL_PARSER_EXCEPTION)
- .setBody("expectTag(\"" + element + "\");\nreturn doParse" + name + "();");
+ parser.addMethod().setPublic().setReturnType(clazz).setName("parse" + name).addThrows(IOException.class).addThrows(XML_PULL_PARSER_EXCEPTION)
+ .setBody("expectTag(\"" + element + "\");\nreturn doParse" + name + "();");
}
if (hasDerived) {
if (!attributeMembers.isEmpty()) {
- parser.addMethod()
- .setSignature(" protected <T extends " + qname + "> AttributeHandler<T> " + lowercase(name) + "AttributeHandler()")
- .setBody("return" + attributes + ";");
+ parser.addMethod().setSignature(" protected <T extends " + qname + "> AttributeHandler<T> " + lowercase(name) + "AttributeHandler()")
+ .setBody("return" + attributes + ";");
}
if (!elementMembers.isEmpty()) {
- parser.addMethod()
- .setSignature(" protected <T extends " + qname + "> ElementHandler<T> " + lowercase(name) + "ElementHandler()")
- .setBody("return" + elements + ";");
+ parser.addMethod().setSignature(" protected <T extends " + qname + "> ElementHandler<T> " + lowercase(name) + "ElementHandler()")
+ .setBody("return" + elements + ";");
}
if (!Modifier.isAbstract(clazz.getModifiers())) {
- parser.addMethod()
- .setSignature(" protected " + qname + " doParse" + name + "() throws IOException, XmlPullParserException")
- .setBody("return doParse(new " + qname + "(), " +
- (attributeMembers.isEmpty() ? attributes : lowercase(name) + "AttributeHandler()") + ", " +
- (elementMembers.isEmpty() ? elements : lowercase(name) + "ElementHandler()") + "," + value + ");\n");
+ parser.addMethod().setSignature(" protected " + qname + " doParse" + name + "() throws IOException, XmlPullParserException")
+ .setBody("return doParse(new " + qname + "(), " + (attributeMembers.isEmpty() ? attributes : lowercase(name) + "AttributeHandler()") + ", "
+ + (elementMembers.isEmpty() ? elements : lowercase(name) + "ElementHandler()") + "," + value + ");\n");
}
} else {
- parser.addMethod()
- .setSignature(" protected " + qname + " doParse" + name + "() throws IOException, XmlPullParserException")
- .setBody("return doParse(new " + qname + "()," + attributes + "," + elements + "," + value + ");\n");
+ parser.addMethod().setSignature(" protected " + qname + " doParse" + name + "() throws IOException, XmlPullParserException")
+ .setBody("return doParse(new " + qname + "()," + attributes + "," + elements + "," + value + ");\n");
}
}
for (Class<?> root : elementRefs) {
parser.addMethod()
- .setSignature(" protected " + root.getSimpleName() + " doParse" + root.getSimpleName() + "Ref(String key) throws IOException, XmlPullParserException")
- .setBody(
- "switch (key) {\n" +
- model.stream()
- .filter(root::isAssignableFrom)
- .filter(cl -> cl.getAnnotation(XmlRootElement.class) != null)
- .map(cl -> {
- String en = cl.getAnnotation(XmlRootElement.class).name();
- if ("##default".equals(en)) {
- en = lowercase(cl.getSimpleName());
- }
- String tn = cl.getSimpleName();
- return " case \"" + en + "\": return doParse" + tn + "();\n";
- })
- .collect(Collectors.joining()) +
- " default: return null;\n" +
- "}"
- );
+ .setSignature(" protected " + root.getSimpleName() + " doParse" + root.getSimpleName() + "Ref(String key) throws IOException, XmlPullParserException")
+ .setBody("switch (key) {\n" + model.stream().filter(root::isAssignableFrom).filter(cl -> cl.getAnnotation(XmlRootElement.class) != null).map(cl -> {
+ String en = cl.getAnnotation(XmlRootElement.class).name();
+ if ("##default".equals(en)) {
+ en = lowercase(cl.getSimpleName());
+ }
+ String tn = cl.getSimpleName();
+ return " case \"" + en + "\": return doParse" + tn + "();\n";
+ }).collect(Collectors.joining()) + " default: return null;\n" + "}");
}
return parser;
@@ -630,8 +483,7 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
Class<?> rawClass = type.getRawClass();
if (rawClass == String.class) {
return val;
- } else if (rawClass.isEnum() || rawClass == Integer.class || rawClass == Long.class
- || rawClass == Boolean.class || rawClass == Float.class) {
+ } else if (rawClass.isEnum() || rawClass == Integer.class || rawClass == Long.class || rawClass == Boolean.class || rawClass == Float.class) {
parser.addImport(rawClass);
return rawClass.getSimpleName() + ".valueOf(" + val + ")";
} else if (rawClass == List.class && type.getActualTypeArgument(0).getRawClass() == String.class) {
@@ -650,12 +502,8 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
}
private List<Member> getMembers(Class<?> clazz) {
- List<Member> members = Stream.concat(
- findFieldsForClass(clazz),
- findMethodsForClass(clazz))
- .filter(m -> ((AnnotatedElement) m).getAnnotation(XmlTransient.class) == null)
- .sorted(Comparator.comparing(member -> member instanceof Method ? propname(member.getName()) : member.getName()))
- .collect(Collectors.toList());
+ List<Member> members = Stream.concat(findFieldsForClass(clazz), findMethodsForClass(clazz)).filter(m -> ((AnnotatedElement)m).getAnnotation(XmlTransient.class) == null)
+ .sorted(Comparator.comparing(member -> member instanceof Method ? propname(member.getName()) : member.getName())).collect(Collectors.toList());
if (clazz != outputDefinitionClass && outputDefinitionClass.isAssignableFrom(clazz)) {
members.removeIf(m -> "setOutputs".equals(m.getName()));
}
@@ -670,19 +518,14 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
accessType = XmlAccessType.PUBLIC_MEMBER;
}
if (accessType == XmlAccessType.FIELD || accessType == XmlAccessType.NONE) {
- return Stream.of(c.getDeclaredMethods())
- .filter(m -> m.getName().startsWith("set") && m.getParameterCount() == 1)
- .filter(m -> m.getAnnotation(XmlAttribute.class) != null
- || m.getAnnotation(XmlElement.class) != null
- || m.getAnnotation(XmlElementRef.class) != null
- || m.getAnnotation(XmlValue.class) != null)
- .sorted(Comparator.comparing(Method::getName));
+ return Stream.of(c.getDeclaredMethods()).filter(m -> m.getName().startsWith("set") && m.getParameterCount() == 1)
+ .filter(m -> m.getAnnotation(XmlAttribute.class) != null || m.getAnnotation(XmlElement.class) != null || m.getAnnotation(XmlElementRef.class) != null
+ || m.getAnnotation(XmlValue.class) != null)
+ .sorted(Comparator.comparing(Method::getName));
} else {
- return Stream.of(c.getDeclaredMethods())
- .filter(m -> Modifier.isPublic(m.getModifiers()) || accessType == XmlAccessType.PROPERTY)
- .filter(m -> m.getName().startsWith("set") && m.getParameterCount() == 1)
- .filter(m -> m.getAnnotation(XmlTransient.class) == null)
- .sorted(Comparator.comparing(Method::getName));
+ return Stream.of(c.getDeclaredMethods()).filter(m -> Modifier.isPublic(m.getModifiers()) || accessType == XmlAccessType.PROPERTY)
+ .filter(m -> m.getName().startsWith("set") && m.getParameterCount() == 1).filter(m -> m.getAnnotation(XmlTransient.class) == null)
+ .sorted(Comparator.comparing(Method::getName));
}
}
@@ -694,18 +537,14 @@ public class ModelXmlParserGeneratorMojo extends AbstractGeneratorMojo {
accessType = XmlAccessType.PUBLIC_MEMBER;
}
if (accessType == XmlAccessType.PROPERTY || accessType == XmlAccessType.NONE) {
- return Stream.of(c.getDeclaredFields())
- .filter(f -> f.getAnnotation(XmlAttribute.class) != null
- || f.getAnnotation(XmlElement.class) != null
- || f.getAnnotation(XmlElementRef.class) != null
- || f.getAnnotation(XmlValue.class) != null)
- .sorted(Comparator.comparing(Field::getName));
+ return Stream
+ .of(c.getDeclaredFields()).filter(f -> f.getAnnotation(XmlAttribute.class) != null || f.getAnnotation(XmlElement.class) != null
+ || f.getAnnotation(XmlElementRef.class) != null || f.getAnnotation(XmlValue.class) != null)
+ .sorted(Comparator.comparing(Field::getName));
} else {
- return Stream.of(c.getDeclaredFields())
- .filter(f -> !Modifier.isTransient(f.getModifiers()) && !Modifier.isStatic(f.getModifiers()))
- .filter(f -> Modifier.isPublic(f.getModifiers()) || accessType == XmlAccessType.FIELD)
- .filter(f -> f.getAnnotation(XmlTransient.class) == null)
- .sorted(Comparator.comparing(Field::getName));
+ return Stream.of(c.getDeclaredFields()).filter(f -> !Modifier.isTransient(f.getModifiers()) && !Modifier.isStatic(f.getModifiers()))
+ .filter(f -> Modifier.isPublic(f.getModifiers()) || accessType == XmlAccessType.FIELD).filter(f -> f.getAnnotation(XmlTransient.class) == null)
+ .sorted(Comparator.comparing(Field::getName));
}
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageArchetypeCatalogMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageArchetypeCatalogMojo.java
index 77d44b3..fa55c4f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageArchetypeCatalogMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageArchetypeCatalogMojo.java
@@ -65,9 +65,10 @@ public class PackageArchetypeCatalogMojo extends AbstractMojo {
/**
* Execute goal.
*
- * @throws org.apache.maven.plugin.MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws org.apache.maven.plugin.MojoFailureException something bad happened...
+ * @throws org.apache.maven.plugin.MojoExecutionException execution of the
+ * main class or one of the threads it generated failed.
+ * @throws org.apache.maven.plugin.MojoFailureException something bad
+ * happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -97,7 +98,6 @@ public class PackageArchetypeCatalogMojo extends AbstractMojo {
}
});
-
List<ArchetypeModel> models = new ArrayList<>();
for (File dir : dirs) {
@@ -109,7 +109,8 @@ public class PackageArchetypeCatalogMojo extends AbstractMojo {
boolean parent = false;
ArchetypeModel model = new ArchetypeModel();
- // just use a simple line by line text parser (no need for DOM) just to grab 4 lines of data
+ // just use a simple line by line text parser (no need for DOM) just
+ // to grab 4 lines of data
for (Object o : FileUtils.readLines(pom, StandardCharsets.UTF_8)) {
String line = o.toString();
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
index fd13e18..747e8a2 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
@@ -37,7 +37,8 @@ import org.sonatype.plexus.build.incremental.BuildContext;
import static org.apache.camel.tooling.util.PackageHelper.loadText;
/**
- * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ * Analyses the Camel plugins in a project and generates extra descriptor
+ * information for easier auto-discovery in Camel.
*/
@Mojo(name = "generate-components-list", threadSafe = true)
public class PackageComponentMojo extends AbstractGeneratorMojo {
@@ -58,7 +59,7 @@ public class PackageComponentMojo extends AbstractGeneratorMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
+ * threads it generated failed.
* @throws MojoFailureException something bad happened...
*/
@Override
@@ -66,12 +67,14 @@ public class PackageComponentMojo extends AbstractGeneratorMojo {
prepareComponent(getLog(), project, projectHelper, buildDir, componentOutDir, buildContext);
}
- public static int prepareComponent(Log log, MavenProject project, MavenProjectHelper projectHelper, File buildDir, File componentOutDir, BuildContext buildContext) throws MojoExecutionException {
+ public static int prepareComponent(Log log, MavenProject project, MavenProjectHelper projectHelper, File buildDir, File componentOutDir, BuildContext buildContext)
+ throws MojoExecutionException {
File camelMetaDir = new File(componentOutDir, "META-INF/services/org/apache/camel/");
// first we need to setup the output directory because the next check
- // can stop the build before the end and eclipse always needs to know about that directory
+ // can stop the build before the end and eclipse always needs to know
+ // about that directory
if (projectHelper != null) {
projectHelper.addResource(project, componentOutDir.getPath(), Collections.singletonList("**/component.properties"), Collections.emptyList());
}
@@ -90,7 +93,8 @@ public class PackageComponentMojo extends AbstractGeneratorMojo {
File[] files = f.listFiles();
if (files != null) {
for (File file : files) {
- // skip directories as there may be a sub .resolver directory
+ // skip directories as there may be a sub .resolver
+ // directory
if (file.isDirectory()) {
continue;
}
@@ -108,7 +112,8 @@ public class PackageComponentMojo extends AbstractGeneratorMojo {
}
if (count > 0) {
- // we need to enrich the component json files with data we know have from this plugin
+ // we need to enrich the component json files with data we know have
+ // from this plugin
enrichComponentJsonFiles(log, project, buildDir, components);
}
@@ -140,10 +145,12 @@ public class PackageComponentMojo extends AbstractGeneratorMojo {
text = text.replace("@@@ARTIFACTID@@@", project.getArtifactId());
text = text.replace("@@@VERSIONID@@@", project.getVersion());
- // special for deprecated where you can quickly specify that in the pom.xml name
+ // special for deprecated where you can quickly specify that
+ // in the pom.xml name
boolean deprecated = project.getName().contains("(deprecated)");
if (deprecated) {
- // must start with 4 leading spaces as we want to replace the marker in the top of the file
+ // must start with 4 leading spaces as we want to
+ // replace the marker in the top of the file
text = text.replaceFirst(" {4}\"deprecated\": false,", " \"deprecated\": true,");
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
index cba5a22..069a0c0 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
@@ -40,7 +40,8 @@ import static org.apache.camel.tooling.util.PackageHelper.loadText;
import static org.apache.camel.tooling.util.PackageHelper.parseAsMap;
/**
- * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ * Analyses the Camel plugins in a project and generates extra descriptor
+ * information for easier auto-discovery in Camel.
*/
@Mojo(name = "generate-dataformats-list", threadSafe = true)
public class PackageDataFormatMojo extends AbstractGeneratorMojo {
@@ -60,22 +61,24 @@ public class PackageDataFormatMojo extends AbstractGeneratorMojo {
/**
* Execute goal.
*
- * @throws org.apache.maven.plugin.MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws org.apache.maven.plugin.MojoFailureException something bad happened...
+ * @throws org.apache.maven.plugin.MojoExecutionException execution of the
+ * main class or one of the threads it generated failed.
+ * @throws org.apache.maven.plugin.MojoFailureException something bad
+ * happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
prepareDataFormat(getLog(), project, projectHelper, dataFormatOutDir, schemaOutDir, buildContext);
}
- public static int prepareDataFormat(Log log, MavenProject project, MavenProjectHelper projectHelper, File dataFormatOutDir,
- File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
+ public static int prepareDataFormat(Log log, MavenProject project, MavenProjectHelper projectHelper, File dataFormatOutDir, File schemaOutDir, BuildContext buildContext)
+ throws MojoExecutionException {
File camelMetaDir = new File(dataFormatOutDir, "META-INF/services/org/apache/camel/");
// first we need to setup the output directory because the next check
- // can stop the build before the end and eclipse always needs to know about that directory
+ // can stop the build before the end and eclipse always needs to know
+ // about that directory
if (projectHelper != null) {
projectHelper.addResource(project, dataFormatOutDir.getPath(), Collections.singletonList("**/dataformat.properties"), Collections.emptyList());
}
@@ -106,7 +109,8 @@ public class PackageDataFormatMojo extends AbstractGeneratorMojo {
}
}
- // is this from Apache Camel then the data format is out of the box and we should enrich the json schema with more details
+ // is this from Apache Camel then the data format is out of the box and
+ // we should enrich the json schema with more details
boolean apacheCamel = "org.apache.camel".equals(project.getGroupId());
// find camel-core and grab the data format model from there, and enrich
@@ -141,9 +145,7 @@ public class PackageDataFormatMojo extends AbstractGeneratorMojo {
}
// write this to the directory
- Path out = schemaOutDir.toPath()
- .resolve(schemaSubDirectory(dataFormatModel.getJavaType()))
- .resolve(name + ".json");
+ Path out = schemaOutDir.toPath().resolve(schemaSubDirectory(dataFormatModel.getJavaType())).resolve(name + ".json");
updateResource(buildContext, out, schema);
if (log.isDebugEnabled()) {
@@ -151,7 +153,8 @@ public class PackageDataFormatMojo extends AbstractGeneratorMojo {
}
}
} else {
- throw new MojoExecutionException("Error finding core/camel-core/target/camel-core-engine-" + project.getVersion() + ".jar file. Make sure camel-core has been built first.");
+ throw new MojoExecutionException("Error finding core/camel-core/target/camel-core-engine-" + project.getVersion()
+ + ".jar file. Make sure camel-core has been built first.");
}
}
} catch (Exception e) {
@@ -499,19 +502,9 @@ public class PackageDataFormatMojo extends AbstractGeneratorMojo {
@Override
public String toString() {
- return "DataFormatModel["
- + "name='" + name + '\''
- + ", title='" + title + '\''
- + ", modelName='" + modelName + '\''
- + ", description='" + description + '\''
- + ", label='" + label + '\''
- + ", deprecated='" + deprecated + '\''
- + ", javaType='" + javaType + '\''
- + ", modelJavaType='" + modelJavaType + '\''
- + ", groupId='" + groupId + '\''
- + ", artifactId='" + artifactId + '\''
- + ", version='" + version + '\''
- + ']';
+ return "DataFormatModel[" + "name='" + name + '\'' + ", title='" + title + '\'' + ", modelName='" + modelName + '\'' + ", description='" + description + '\''
+ + ", label='" + label + '\'' + ", deprecated='" + deprecated + '\'' + ", javaType='" + javaType + '\'' + ", modelJavaType='" + modelJavaType + '\''
+ + ", groupId='" + groupId + '\'' + ", artifactId='" + artifactId + '\'' + ", version='" + version + '\'' + ']';
}
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java
index d6f8e06..9a13682 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java
@@ -52,7 +52,8 @@ import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
/**
- * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ * Analyses the Camel plugins in a project and generates extra descriptor
+ * information for easier auto-discovery in Camel.
*/
@Mojo(name = "generate-jaxb-list", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES)
public class PackageJaxbMojo extends AbstractGeneratorMojo {
@@ -67,7 +68,7 @@ public class PackageJaxbMojo extends AbstractGeneratorMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
+ * threads it generated failed.
* @throws MojoFailureException something bad happened...
*/
@Override
@@ -84,30 +85,19 @@ public class PackageJaxbMojo extends AbstractGeneratorMojo {
private void processClasses(IndexView index) {
Map<String, Set<String>> byPackage = new HashMap<>();
- Stream.of(XmlRootElement.class, XmlEnum.class, XmlType.class)
- .map(Class::getName)
- .map(DotName::createSimple)
- .map(index::getAnnotations)
- .flatMap(Collection::stream)
- .map(AnnotationInstance::target)
- .map(AnnotationTarget::asClass)
- .map(ClassInfo::name)
- .map(DotName::toString)
- .forEach(name -> {
- int idx = name.lastIndexOf('.');
- String p = name.substring(0, idx);
- String c = name.substring(idx + 1);
- byPackage.computeIfAbsent(p, s -> new TreeSet<>()).add(c);
- });
+ Stream.of(XmlRootElement.class, XmlEnum.class, XmlType.class).map(Class::getName).map(DotName::createSimple).map(index::getAnnotations).flatMap(Collection::stream)
+ .map(AnnotationInstance::target).map(AnnotationTarget::asClass).map(ClassInfo::name).map(DotName::toString).forEach(name -> {
+ int idx = name.lastIndexOf('.');
+ String p = name.substring(0, idx);
+ String c = name.substring(idx + 1);
+ byPackage.computeIfAbsent(p, s -> new TreeSet<>()).add(c);
+ });
Path jaxbIndexDir = jaxbIndexOutDir.toPath();
int count = 0;
for (Map.Entry<String, Set<String>> entry : byPackage.entrySet()) {
String fn = entry.getKey().replace('.', '/') + "/jaxb.index";
- if (project.getCompileSourceRoots().stream()
- .map(Paths::get)
- .map(p -> p.resolve(fn))
- .anyMatch(Files::isRegularFile)) {
+ if (project.getCompileSourceRoots().stream().map(Paths::get).map(p -> p.resolve(fn)).anyMatch(Files::isRegularFile)) {
continue;
}
Path file = jaxbIndexDir.resolve(fn);
@@ -126,13 +116,8 @@ public class PackageJaxbMojo extends AbstractGeneratorMojo {
private IndexView createIndex(List<String> locations) throws MojoExecutionException {
try {
Indexer indexer = new Indexer();
- locations.stream()
- .map(this::asFolder)
- .filter(Files::isDirectory)
- .flatMap(this::walk)
- .filter(Files::isRegularFile)
- .filter(p -> p.getFileName().toString().endsWith(".class"))
- .forEach(p -> index(indexer, p));
+ locations.stream().map(this::asFolder).filter(Files::isDirectory).flatMap(this::walk).filter(Files::isRegularFile)
+ .filter(p -> p.getFileName().toString().endsWith(".class")).forEach(p -> index(indexer, p));
return indexer.complete();
} catch (IOError e) {
throw new MojoExecutionException("Error", e);
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
index 586ea9f..a408633 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
@@ -41,7 +41,8 @@ import static org.apache.camel.tooling.util.PackageHelper.loadText;
import static org.apache.camel.tooling.util.PackageHelper.parseAsMap;
/**
- * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ * Analyses the Camel plugins in a project and generates extra descriptor
+ * information for easier auto-discovery in Camel.
*/
@Mojo(name = "generate-languages-list", threadSafe = true)
public class PackageLanguageMojo extends AbstractGeneratorMojo {
@@ -67,22 +68,25 @@ public class PackageLanguageMojo extends AbstractGeneratorMojo {
/**
* Execute goal.
*
- * @throws org.apache.maven.plugin.MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws org.apache.maven.plugin.MojoFailureException something bad happened...
+ * @throws org.apache.maven.plugin.MojoExecutionException execution of the
+ * main class or one of the threads it generated failed.
+ * @throws org.apache.maven.plugin.MojoFailureException something bad
+ * happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
prepareLanguage(getLog(), project, projectHelper, buildDir, languageOutDir, schemaOutDir, buildContext);
}
- public static int prepareLanguage(Log log, MavenProject project, MavenProjectHelper projectHelper, File buildDir, File languageOutDir,
- File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
+ public static int prepareLanguage(Log log, MavenProject project, MavenProjectHelper projectHelper, File buildDir, File languageOutDir, File schemaOutDir,
+ BuildContext buildContext)
+ throws MojoExecutionException {
File camelMetaDir = new File(languageOutDir, "META-INF/services/org/apache/camel/");
// first we need to setup the output directory because the next check
- // can stop the build before the end and eclipse always needs to know about that directory
+ // can stop the build before the end and eclipse always needs to know
+ // about that directory
if (projectHelper != null) {
projectHelper.addResource(project, languageOutDir.getPath(), Collections.singletonList("**/language.properties"), Collections.emptyList());
}
@@ -183,9 +187,7 @@ public class PackageLanguageMojo extends AbstractGeneratorMojo {
}
// write this to the directory
- Path out = schemaOutDir.toPath()
- .resolve(schemaSubDirectory(languageModel.getJavaType()))
- .resolve(name + ".json");
+ Path out = schemaOutDir.toPath().resolve(schemaSubDirectory(languageModel.getJavaType())).resolve(name + ".json");
updateResource(buildContext, out, schema);
if (log.isDebugEnabled()) {
@@ -193,7 +195,8 @@ public class PackageLanguageMojo extends AbstractGeneratorMojo {
}
}
} else {
- throw new MojoExecutionException("Error finding core/camel-core/target/camel-core-engine-" + project.getVersion() + ".jar file. Make sure camel-core has been built first.");
+ throw new MojoExecutionException("Error finding core/camel-core/target/camel-core-engine-" + project.getVersion()
+ + ".jar file. Make sure camel-core has been built first.");
}
}
} catch (Exception e) {
@@ -214,7 +217,8 @@ public class PackageLanguageMojo extends AbstractGeneratorMojo {
}
private static String readClassFromCamelResource(File file, StringBuilder buffer, BuildContext buildContext) throws MojoExecutionException {
- // skip directories as there may be a sub .resolver directory such as in camel-script
+ // skip directories as there may be a sub .resolver directory such as in
+ // camel-script
if (file.isDirectory()) {
return null;
}
@@ -430,18 +434,9 @@ public class PackageLanguageMojo extends AbstractGeneratorMojo {
@Override
public String toString() {
- return "LanguageModel["
- + "name='" + name + '\''
- + ", modelName='" + modelName + '\''
- + ", title='" + title + '\''
- + ", description='" + description + '\''
- + ", label='" + label + '\''
- + ", javaType='" + javaType + '\''
- + ", modelJavaType='" + modelJavaType + '\''
- + ", groupId='" + groupId + '\''
- + ", artifactId='" + artifactId + '\''
- + ", version='" + version + '\''
- + ']';
+ return "LanguageModel[" + "name='" + name + '\'' + ", modelName='" + modelName + '\'' + ", title='" + title + '\'' + ", description='" + description + '\''
+ + ", label='" + label + '\'' + ", javaType='" + javaType + '\'' + ", modelJavaType='" + modelJavaType + '\'' + ", groupId='" + groupId + '\'' + ", artifactId='"
+ + artifactId + '\'' + ", version='" + version + '\'' + ']';
}
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
index 58769f9..a08e694 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
@@ -45,7 +45,7 @@ public class PackageLegalMojo extends AbstractGeneratorMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
+ * threads it generated failed.
* @throws MojoFailureException something bad happened...
*/
@Override
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageModelMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageModelMojo.java
index 6084520..e6c3bf1 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageModelMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageModelMojo.java
@@ -31,7 +31,8 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
/**
- * Analyses the Camel EIPs in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ * Analyses the Camel EIPs in a project and generates extra descriptor
+ * information for easier auto-discovery in Camel.
*/
@Mojo(name = "generate-eips-list", threadSafe = true)
public class PackageModelMojo extends AbstractGeneratorMojo {
@@ -51,9 +52,10 @@ public class PackageModelMojo extends AbstractGeneratorMojo {
/**
* Execute goal.
*
- * @throws org.apache.maven.plugin.MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws org.apache.maven.plugin.MojoFailureException something bad happened...
+ * @throws org.apache.maven.plugin.MojoExecutionException execution of the
+ * main class or one of the threads it generated failed.
+ * @throws org.apache.maven.plugin.MojoFailureException something bad
+ * happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java
index 3cfb72e..b2ee6e7 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java
@@ -32,7 +32,8 @@ import org.sonatype.plexus.build.incremental.BuildContext;
import static org.apache.camel.tooling.util.Strings.camelDashToTitle;
/**
- * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ * Analyses the Camel plugins in a project and generates extra descriptor
+ * information for easier auto-discovery in Camel.
*/
@Mojo(name = "generate-others-list", threadSafe = true)
public class PackageOtherMojo extends AbstractGeneratorMojo {
@@ -53,7 +54,7 @@ public class PackageOtherMojo extends AbstractGeneratorMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
+ * threads it generated failed.
* @throws MojoFailureException something bad happened...
*/
@Override
@@ -75,11 +76,12 @@ public class PackageOtherMojo extends AbstractGeneratorMojo {
prepareOthers(getLog(), project, projectHelper, otherOutDir, schemaOutDir, buildContext);
}
- public static void prepareOthers(Log log, MavenProject project, MavenProjectHelper projectHelper, File otherOutDir,
- File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
+ public static void prepareOthers(Log log, MavenProject project, MavenProjectHelper projectHelper, File otherOutDir, File schemaOutDir, BuildContext buildContext)
+ throws MojoExecutionException {
// first we need to setup the output directory because the next check
- // can stop the build before the end and eclipse always needs to know about that directory
+ // can stop the build before the end and eclipse always needs to know
+ // about that directory
if (projectHelper != null) {
projectHelper.addResource(project, otherOutDir.getPath(), Collections.singletonList("**/other.properties"), Collections.emptyList());
}
@@ -118,8 +120,7 @@ public class PackageOtherMojo extends AbstractGeneratorMojo {
String schema = createJsonSchema(otherModel);
// write this to the directory
- Path out = schemaOutDir.toPath()
- .resolve(name + ".json");
+ Path out = schemaOutDir.toPath().resolve(name + ".json");
updateResource(buildContext, out, schema);
if (log.isDebugEnabled()) {
@@ -259,15 +260,8 @@ public class PackageOtherMojo extends AbstractGeneratorMojo {
@Override
public String toString() {
- return "OtherModel["
- + "name='" + name + '\''
- + ", title='" + title + '\''
- + ", description='" + description + '\''
- + ", label='" + label + '\''
- + ", groupId='" + groupId + '\''
- + ", artifactId='" + artifactId + '\''
- + ", version='" + version + '\''
- + ']';
+ return "OtherModel[" + "name='" + name + '\'' + ", title='" + title + '\'' + ", description='" + description + '\'' + ", label='" + label + '\'' + ", groupId='"
+ + groupId + '\'' + ", artifactId='" + artifactId + '\'' + ", version='" + version + '\'' + ']';
}
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
index a0c5c84..81dac41 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
@@ -118,8 +118,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws MojoFailureException something bad happened...
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -244,10 +244,9 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
File[] languages = componentsDir.listFiles();
if (languages != null) {
for (File dir : languages) {
- // the directory must be in the list of known features (or known languages)
- if (!features.contains(dir.getName())
- && !dir.getName().equals("camel-bean")
- && !dir.getName().equals("camel-xpath")) {
+ // the directory must be in the list of known features (or
+ // known languages)
+ if (!features.contains(dir.getName()) && !dir.getName().equals("camel-bean") && !dir.getName().equals("camel-xpath")) {
continue;
}
@@ -300,17 +299,10 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
}
// skip these special cases
- boolean special = "camel-core-osgi".equals(dir.getName())
- || "camel-core-xml".equals(dir.getName())
- || "camel-http-base".equals(dir.getName())
- || "camel-http-common".equals(dir.getName())
- || "camel-jetty-common".equals(dir.getName());
- boolean special2 = "camel-as2".equals(dir.getName())
- || "camel-box".equals(dir.getName())
- || "camel-olingo2".equals(dir.getName())
- || "camel-olingo4".equals(dir.getName())
- || "camel-servicenow".equals(dir.getName())
- || "camel-salesforce".equals(dir.getName());
+ boolean special = "camel-core-osgi".equals(dir.getName()) || "camel-core-xml".equals(dir.getName()) || "camel-http-base".equals(dir.getName())
+ || "camel-http-common".equals(dir.getName()) || "camel-jetty-common".equals(dir.getName());
+ boolean special2 = "camel-as2".equals(dir.getName()) || "camel-box".equals(dir.getName()) || "camel-olingo2".equals(dir.getName())
+ || "camel-olingo4".equals(dir.getName()) || "camel-servicenow".equals(dir.getName()) || "camel-salesforce".equals(dir.getName());
boolean special3 = "camel-debezium-common".equals(dir.getName());
if (special || special2 || special3) {
continue;
@@ -343,7 +335,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
boolean componentFile = !rootDir && file.isFile() && file.getName().equals("component.properties");
@@ -362,7 +355,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
boolean dataFormatFile = !rootDir && file.isFile() && file.getName().equals("dataformat.properties");
@@ -381,7 +375,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
boolean languageFile = !rootDir && file.isFile() && file.getName().equals("language.properties");
@@ -400,7 +395,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = rootDir && file.isFile() && file.getName().endsWith(".json");
boolean otherFile = !rootDir && file.isFile() && file.getName().equals("other.properties");
@@ -420,7 +416,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory() && pathname.getName().equals("model")) {
- // do not check the camel-core model packages as there is no components there
+ // do not check the camel-core model packages as there is no
+ // components there
return false;
}
if (pathname.isFile() && pathname.getName().endsWith(".json")) {
@@ -432,8 +429,7 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
// ignore
}
}
- return pathname.isDirectory()
- || (pathname.isFile() && pathname.getName().equals("component.properties"));
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("component.properties"));
}
}
@@ -442,7 +438,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory() && pathname.getName().equals("model")) {
- // do not check the camel-core model packages as there is no components there
+ // do not check the camel-core model packages as there is no
+ // components there
return false;
}
if (pathname.isFile() && pathname.getName().endsWith(".json")) {
@@ -454,8 +451,7 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
// ignore
}
}
- return pathname.isDirectory()
- || (pathname.isFile() && pathname.getName().equals("dataformat.properties"));
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("dataformat.properties"));
}
}
@@ -464,7 +460,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory() && pathname.getName().equals("model")) {
- // do not check the camel-core model packages as there is no components there
+ // do not check the camel-core model packages as there is no
+ // components there
return false;
}
if (pathname.isFile() && pathname.getName().endsWith(".json")) {
@@ -476,8 +473,7 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
// ignore
}
}
- return pathname.isDirectory()
- || (pathname.isFile() && pathname.getName().equals("language.properties"));
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("language.properties"));
}
}
@@ -494,8 +490,7 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
// ignore
}
}
- return pathname.isDirectory()
- || (pathname.isFile() && pathname.getName().equals("other.properties"));
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("other.properties"));
}
}
@@ -513,13 +508,9 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
public static Set<String> generateJsonList(Path outDir, String outFile) throws MojoFailureException {
Path all = outDir.resolve(outFile);
try {
- Set<String> answer = Files.list(outDir)
- .filter(p -> p.getFileName().toString().endsWith(".json"))
- .map(p -> p.getFileName().toString())
- // strip out .json from the name
- .map(n -> n.substring(0, n.length() - ".json".length()))
- .sorted()
- .collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
+ Set<String> answer = Files.list(outDir).filter(p -> p.getFileName().toString().endsWith(".json")).map(p -> p.getFileName().toString())
+ // strip out .json from the name
+ .map(n -> n.substring(0, n.length() - ".json".length())).sorted().collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
String data = String.join("\n", answer) + "\n";
FileUtil.updateFile(all, data);
return answer;
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java
index 3dc6cd3..bff777c 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java
@@ -54,17 +54,13 @@ import org.asciidoctor.OptionsBuilder;
import static org.apache.camel.tooling.util.PackageHelper.loadText;
/**
- * Prepares the camel catalog to include component, data format, and eip descriptors,
- * and generates a report.
+ * Prepares the camel catalog to include component, data format, and eip
+ * descriptors, and generates a report.
*/
@Mojo(name = "prepare-catalog", threadSafe = true)
public class PrepareCatalogMojo extends AbstractMojo {
- private static final String[] EXCLUDE_DOC_FILES = {
- "camel-core-osgi", "camel-core-xml",
- "camel-http-common", "camel-http-base", "camel-jetty-common",
- "camel-debezium-common"
- };
+ private static final String[] EXCLUDE_DOC_FILES = {"camel-core-osgi", "camel-core-xml", "camel-http-common", "camel-http-base", "camel-jetty-common", "camel-debezium-common"};
private static final Pattern LABEL_PATTERN = Pattern.compile("\\\"label\\\":\\s\\\"([\\w,]+)\\\"");
@@ -77,7 +73,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
protected MavenProject project;
/**
- * Whether to validate if the components, data formats, and languages are properly documented and have all the needed details.
+ * Whether to validate if the components, data formats, and languages are
+ * properly documented and have all the needed details.
*/
@Parameter(defaultValue = "true")
protected Boolean validate;
@@ -102,7 +99,6 @@ public class PrepareCatalogMojo extends AbstractMojo {
/**
* The output directory for others catalog
- *
*/
@Parameter(defaultValue = "${project.build.directory}/classes/org/apache/camel/catalog/others")
protected File othersOutDir;
@@ -194,9 +190,10 @@ public class PrepareCatalogMojo extends AbstractMojo {
/**
* Execute goal.
*
- * @throws org.apache.maven.plugin.MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws org.apache.maven.plugin.MojoFailureException something bad happened...
+ * @throws org.apache.maven.plugin.MojoExecutionException execution of the
+ * main class or one of the threads it generated failed.
+ * @throws org.apache.maven.plugin.MojoFailureException something bad
+ * happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -435,7 +432,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
}
- // check if we have a component label as we want the components to include labels
+ // check if we have a component label as we want the components to
+ // include labels
try {
String text = loadText(file);
String name = asComponentName(file);
@@ -450,7 +448,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
}
- // check all the component options and grab the label(s) they use
+ // check all the component options and grab the label(s) they
+ // use
List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("componentProperties", text, true);
for (Map<String, String> row : rows) {
String label = row.get("label");
@@ -505,12 +504,12 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
}
- Set<String> componentNames =
- generateJsonList(componentsOutDir.toPath(), "../components.properties");
+ Set<String> componentNames = generateJsonList(componentsOutDir.toPath(), "../components.properties");
printComponentsReport(jsonFiles, duplicateJsonFiles, missingComponents, usedComponentLabels, usedOptionLabels, unlabeledOptions, missingFirstVersions);
- // filter out duplicate component names that are alternative scheme names
+ // filter out duplicate component names that are alternative scheme
+ // names
componentNames.removeAll(alternativeSchemes);
return componentNames;
}
@@ -579,7 +578,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
}
- // check if we have a label as we want the data format to include labels
+ // check if we have a label as we want the data format to include
+ // labels
try {
String text = loadText(file);
String name = asComponentName(file);
@@ -611,8 +611,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
}
- Set<String> answer =
- generateJsonList(dataFormatsOutDir.toPath(), "../dataformats.properties");
+ Set<String> answer = generateJsonList(dataFormatsOutDir.toPath(), "../dataformats.properties");
printDataFormatsReport(jsonFiles, duplicateJsonFiles, usedLabels, missingFirstVersions);
@@ -681,7 +680,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
}
- // check if we have a label as we want the data format to include labels
+ // check if we have a label as we want the data format to include
+ // labels
try {
String text = loadText(file);
String name = asComponentName(file);
@@ -713,8 +713,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
}
- Set<String> answer =
- generateJsonList(languagesOutDir.toPath(), "../languages.properties");
+ Set<String> answer = generateJsonList(languagesOutDir.toPath(), "../languages.properties");
printLanguagesReport(jsonFiles, duplicateJsonFiles, usedLabels, missingFirstVersions);
@@ -738,18 +737,10 @@ public class PrepareCatalogMojo extends AbstractMojo {
for (File dir : others) {
// skip these special cases
- boolean special = "camel-core-osgi".equals(dir.getName())
- || "camel-core-xml".equals(dir.getName())
- || "camel-box".equals(dir.getName())
- || "camel-http-base".equals(dir.getName())
- || "camel-http-common".equals(dir.getName())
- || "camel-jetty-common".equals(dir.getName());
- boolean special2 = "camel-as2".equals(dir.getName())
- || "camel-olingo2".equals(dir.getName())
- || "camel-olingo4".equals(dir.getName())
- || "camel-servicenow".equals(dir.getName())
- || "camel-salesforce".equals(dir.getName())
- || "camel-fhir".equals(dir.getName());
+ boolean special = "camel-core-osgi".equals(dir.getName()) || "camel-core-xml".equals(dir.getName()) || "camel-box".equals(dir.getName())
+ || "camel-http-base".equals(dir.getName()) || "camel-http-common".equals(dir.getName()) || "camel-jetty-common".equals(dir.getName());
+ boolean special2 = "camel-as2".equals(dir.getName()) || "camel-olingo2".equals(dir.getName()) || "camel-olingo4".equals(dir.getName())
+ || "camel-servicenow".equals(dir.getName()) || "camel-salesforce".equals(dir.getName()) || "camel-fhir".equals(dir.getName());
boolean special3 = "camel-debezium-common".equals(dir.getName());
if (special || special2 || special3) {
continue;
@@ -897,7 +888,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
}
- protected void executeDocuments(Set<String> components, Set<String> dataformats, Set<String> languages, Set<String> others) throws MojoExecutionException, MojoFailureException {
+ protected void executeDocuments(Set<String> components, Set<String> dataformats, Set<String> languages, Set<String> others)
+ throws MojoExecutionException, MojoFailureException {
getLog().info("Copying all Camel documents (ascii docs)");
// lets use sorted set/maps
@@ -967,7 +959,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
// we only want to warn for duplicates if its a clean build
boolean warnDups = documentsOutDir.list() == null || documentsOutDir.list().length == 0;
- // use ascii doctor to convert the adoc files to html so we have documentation in this format as well
+ // use ascii doctor to convert the adoc files to html so we have
+ // documentation in this format as well
Asciidoctor asciidoctor = Asciidoctor.Factory.create();
int converted = 0;
@@ -1002,7 +995,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
converted++;
try {
- // now fix the html file because we don't want to include certain lines
+ // now fix the html file because we don't want to include
+ // certain lines
List<String> lines = FileUtils.readLines(toHtml, Charset.defaultCharset());
List<String> output = new ArrayList<>();
for (String line : lines) {
@@ -1058,7 +1052,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
printDocumentsReport(adocFiles, duplicateAdocFiles, missingAdocFiles);
- // find out if we have documents for each component / dataformat / languages / others
+ // find out if we have documents for each component / dataformat /
+ // languages / others
printMissingDocumentsReport(docs, components, dataformats, languages, others);
}
@@ -1070,11 +1065,12 @@ public class PrepareCatalogMojo extends AbstractMojo {
List<String> missing = new ArrayList<>();
for (String component : components) {
// special for mail
- if (component.equals("imap") || component.equals("imaps") || component.equals("pop3") || component.equals("pop3s") || component.equals("smtp") || component.equals("smtps")) {
+ if (component.equals("imap") || component.equals("imaps") || component.equals("pop3") || component.equals("pop3s") || component.equals("smtp")
+ || component.equals("smtps")) {
component = "mail";
} else if (component.equals("ftp") || component.equals("sftp") || component.equals("ftps")) {
component = "ftp";
- }
+ }
String name = component + "-component";
if (!docs.contains(name) && (!component.equalsIgnoreCase("salesforce") && !component.equalsIgnoreCase("servicenow"))) {
missing.add(name);
@@ -1187,8 +1183,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
getLog().info("================================================================================");
}
- private void printComponentsReport(Set<File> json, Set<File> duplicate, Set<File> missing, Map<String,
- Set<String>> usedComponentLabels, Set<String> usedOptionsLabels, Set<String> unusedLabels, Set<File> missingFirstVersions) {
+ private void printComponentsReport(Set<File> json, Set<File> duplicate, Set<File> missing, Map<String, Set<String>> usedComponentLabels, Set<String> usedOptionsLabels,
+ Set<String> unusedLabels, Set<File> missingFirstVersions) {
getLog().info("================================================================================");
getLog().info("");
getLog().info("Camel component catalog report");
@@ -1397,7 +1393,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
boolean componentFile = !rootDir && file.isFile() && file.getName().equals("component.properties");
@@ -1416,7 +1413,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
boolean dataFormatFile = !rootDir && file.isFile() && file.getName().equals("dataformat.properties");
@@ -1435,7 +1433,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
boolean languageFile = !rootDir && file.isFile() && file.getName().equals("language.properties");
@@ -1454,7 +1453,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean jsonFile = rootDir && file.isFile() && file.getName().endsWith(".json");
boolean otherFile = !rootDir && file.isFile() && file.getName().equals("other.properties");
@@ -1473,7 +1473,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
File[] files = dir.listFiles(filter);
if (files != null) {
for (File file : files) {
- // skip files in root dirs as Camel does not store information there but others may do
+ // skip files in root dirs as Camel does not store information
+ // there but others may do
boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
boolean adocFile = !rootDir && file.isFile() && file.getName().endsWith(".adoc");
if (adocFile) {
@@ -1490,7 +1491,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory() && pathname.getName().equals("model")) {
- // do not check the camel-core model packages as there is no components there
+ // do not check the camel-core model packages as there is no
+ // components there
return false;
}
if (pathname.isFile() && pathname.getName().endsWith(".json")) {
@@ -1511,7 +1513,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory() && pathname.getName().equals("model")) {
- // do not check the camel-core model packages as there is no components there
+ // do not check the camel-core model packages as there is no
+ // components there
return false;
}
if (pathname.isFile() && pathname.getName().endsWith(".json")) {
@@ -1532,7 +1535,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory() && pathname.getName().equals("model")) {
- // do not check the camel-core model packages as there is no components there
+ // do not check the camel-core model packages as there is no
+ // components there
return false;
}
if (pathname.isFile() && pathname.getName().endsWith(".json")) {
@@ -1577,13 +1581,9 @@ public class PrepareCatalogMojo extends AbstractMojo {
Set<String> answer;
Path all = outDir.resolve(outFile);
try {
- answer = Files.list(outDir)
- .filter(p -> p.getFileName().toString().endsWith(".json"))
- .map(p -> p.getFileName().toString())
- // strip out .json from the name
- .map(n -> n.substring(0, n.length() - ".json".length()))
- .sorted()
- .collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
+ answer = Files.list(outDir).filter(p -> p.getFileName().toString().endsWith(".json")).map(p -> p.getFileName().toString())
+ // strip out .json from the name
+ .map(n -> n.substring(0, n.length() - ".json".length())).sorted().collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
String data = String.join("\n", answer) + "\n";
FileUtil.updateFile(all, data);
return answer;
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java
index f39205f..5752db1 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java
@@ -36,12 +36,13 @@ import static org.apache.camel.maven.packaging.PackageOtherMojo.prepareOthers;
/**
* Prepares a Camel component analyzing if the maven module contains Camel
* <ul>
- * <li>components</li>
- * <li>dataformats</li>
- * <li>languages</li>
- * <li>others</li>
+ * <li>components</li>
+ * <li>dataformats</li>
+ * <li>languages</li>
+ * <li>others</li>
* </ul>
- * And for each of those generates extra descriptors and schema files for easier auto-discovery in Camel and tooling.
+ * And for each of those generates extra descriptors and schema files for easier
+ * auto-discovery in Camel and tooling.
*/
@Mojo(name = "prepare-components", threadSafe = true)
public class PrepareComponentMojo extends AbstractMojo {
@@ -54,42 +55,36 @@ public class PrepareComponentMojo extends AbstractMojo {
/**
* The output directory for generated components file
- *
*/
@Parameter(defaultValue = "${project.build.directory}/generated/camel/components")
protected File componentOutDir;
/**
* The output directory for generated dataformats file
- *
*/
@Parameter(defaultValue = "${project.build.directory}/generated/camel/dataformats")
protected File dataFormatOutDir;
/**
* The output directory for generated languages file
- *
*/
@Parameter(defaultValue = "${project.build.directory}/generated/camel/languages")
protected File languageOutDir;
/**
* The output directory for generated others file
- *
*/
@Parameter(defaultValue = "${project.build.directory}/generated/camel/others")
protected File otherOutDir;
/**
* The output directory for generated schema file
- *
*/
@Parameter(defaultValue = "${project.build.directory}/classes")
protected File schemaOutDir;
/**
* The project build directory
- *
*/
@Parameter(defaultValue = "${project.build.directory}")
protected File buildDir;
@@ -101,8 +96,8 @@ public class PrepareComponentMojo extends AbstractMojo {
private MavenProjectHelper projectHelper;
/**
- * build context to check changed files and mark them for refresh
- * (used for m2e compatibility)
+ * build context to check changed files and mark them for refresh (used for
+ * m2e compatibility)
*/
@Component
private BuildContext buildContext;
@@ -110,9 +105,10 @@ public class PrepareComponentMojo extends AbstractMojo {
/**
* Execute goal.
*
- * @throws org.apache.maven.plugin.MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws org.apache.maven.plugin.MojoFailureException something bad happened...
+ * @throws org.apache.maven.plugin.MojoExecutionException execution of the
+ * main class or one of the threads it generated failed.
+ * @throws org.apache.maven.plugin.MojoFailureException something bad
+ * happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
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 923f9dd..84ae65d 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
@@ -47,7 +47,8 @@ import static org.apache.camel.tooling.util.PackageHelper.loadText;
import static org.apache.camel.tooling.util.PackageHelper.writeText;
/**
- * Prepares the readme.md files content up to date with all the examples that Apache Camel ships.
+ * Prepares the readme.md files content up to date with all the examples that
+ * Apache Camel ships.
*/
@Mojo(name = "prepare-example", threadSafe = true)
public class PrepareExampleMojo extends AbstractMojo {
@@ -68,8 +69,8 @@ public class PrepareExampleMojo extends AbstractMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws MojoFailureException something bad happened...
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -79,7 +80,8 @@ 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
+ // 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;
@@ -142,9 +144,7 @@ public class PrepareExampleMojo extends AbstractMojo {
models.sort(new ExampleComparator());
// how many deprecated
- long deprecated = models.stream()
- .filter(m -> "true".equals(m.getDeprecated()))
- .count();
+ long deprecated = models.stream().filter(m -> "true".equals(m.getDeprecated())).count();
// update the big readme file in the examples dir
File file = new File(".", "README.adoc");
@@ -173,7 +173,7 @@ public class PrepareExampleMojo extends AbstractMojo {
Map<String, Object> map = new HashMap<>();
map.put("examples", models);
map.put("numberOfDeprecated", deprecated);
- String out = (String) TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
+ String out = (String)TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
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/PrepareParentPomMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareParentPomMojo.java
index 103a12b..6bb8f2f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareParentPomMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareParentPomMojo.java
@@ -72,8 +72,8 @@ public class PrepareParentPomMojo extends AbstractMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws MojoFailureException something bad happened...
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareReleasePomMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareReleasePomMojo.java
index 5874462..a619bdf 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareReleasePomMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareReleasePomMojo.java
@@ -39,7 +39,8 @@ import static org.apache.camel.tooling.util.PackageHelper.writeText;
import static org.apache.camel.tooling.util.Strings.between;
/**
- * Prepares the apache-camel/pom.xml and common-bin to keep the Camel artifacts up-to-date.
+ * Prepares the apache-camel/pom.xml and common-bin to keep the Camel artifacts
+ * up-to-date.
*/
@Mojo(name = "prepare-release-pom", threadSafe = true)
public class PrepareReleasePomMojo extends AbstractMojo {
@@ -78,8 +79,8 @@ public class PrepareReleasePomMojo extends AbstractMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws MojoFailureException something bad happened...
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareUserGuideMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareUserGuideMojo.java
index 75f14c4..3157044 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareUserGuideMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareUserGuideMojo.java
@@ -48,7 +48,8 @@ import static org.apache.camel.tooling.util.JSonSchemaHelper.getSafeValue;
import static org.apache.camel.tooling.util.JSonSchemaHelper.parseJsonSchema;
/**
- * Prepares the user guide to keep the table of content up to date with the components, data formats, and languages.
+ * Prepares the user guide to keep the table of content up to date with the
+ * components, data formats, and languages.
*/
@Mojo(name = "prepare-user-guide", threadSafe = true)
public class PrepareUserGuideMojo extends AbstractMojo {
@@ -99,8 +100,8 @@ public class PrepareUserGuideMojo extends AbstractMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws MojoFailureException something bad happened...
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateDocComponentListMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateDocComponentListMojo.java
index 36c7cce..3d0db8c 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateDocComponentListMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateDocComponentListMojo.java
@@ -50,7 +50,8 @@ import static org.apache.camel.tooling.util.JSonSchemaHelper.getSafeValue;
import static org.apache.camel.tooling.util.JSonSchemaHelper.parseJsonSchema;
/**
- * Updates the website docs with the component list to be up to date with all the artifacts that Apache Camel ships.
+ * Updates the website docs with the component list to be up to date with all
+ * the artifacts that Apache Camel ships.
*/
@Mojo(name = "update-doc-component-list", threadSafe = true)
public class UpdateDocComponentListMojo extends AbstractMojo {
@@ -101,8 +102,8 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
* Execute goal.
*
* @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws MojoFailureException something bad happened...
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -139,7 +140,8 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
if (add) {
models.add(model);
- // special for camel-mail where we want to refer its imap scheme to mail so its mail.adoc in the doc link
+ // special for camel-mail where we want to refer its imap
+ // scheme to mail so its mail.adoc in the doc link
if ("imap".equals(model.getScheme())) {
model.setScheme("mail");
model.setTitle("Mail");
@@ -151,15 +153,10 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
models.sort(new ComponentComparator());
// how many different artifacts
- long count = models.stream()
- .map(ComponentModel::getArtifactId)
- .distinct()
- .count();
+ long count = models.stream().map(ComponentModel::getArtifactId).distinct().count();
// how many deprecated
- long deprecated = models.stream()
- .filter(c -> "true".equals(c.getDeprecated()))
- .count();
+ long deprecated = models.stream().filter(c -> "true".equals(c.getDeprecated())).count();
// update doc in the website dir
File file = websiteDocFile;
@@ -200,15 +197,10 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
others.sort(new OtherComparator());
// how many different artifacts
- long count = others.stream()
- .map(OtherModel::getArtifactId)
- .distinct()
- .count();
+ long count = others.stream().map(OtherModel::getArtifactId).distinct().count();
// how many deprecated
- long deprecated = others.stream()
- .filter(o -> "true".equals(o.getDeprecated()))
- .count();
+ long deprecated = others.stream().filter(o -> "true".equals(o.getDeprecated())).count();
// update doc in the website dir
File file = websiteDocFile;
@@ -256,15 +248,10 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
models.sort(new DataFormatComparator());
// how many different artifacts
- long count = models.stream()
- .map(DataFormatModel::getArtifactId)
- .distinct()
- .count();
+ long count = models.stream().map(DataFormatModel::getArtifactId).distinct().count();
// how many deprecated
- long deprecated = models.stream()
- .filter(m -> "true".equals(m.getDeprecated()))
- .count();
+ long deprecated = models.stream().filter(m -> "true".equals(m.getDeprecated())).count();
// update doc in the website dir
File file = websiteDocFile;
@@ -306,15 +293,10 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
models.sort(new LanguageComparator());
// how many different artifacts
- long count = models.stream()
- .map(LanguageModel::getArtifactId)
- .distinct()
- .count();
+ long count = models.stream().map(LanguageModel::getArtifactId).distinct().count();
// how many deprecated
- long deprecated = models.stream()
- .filter(l -> "true".equals(l.getDeprecated()))
- .count();
+ long deprecated = models.stream().filter(l -> "true".equals(l.getDeprecated())).count();
// update doc in the website dir
File file = websiteDocFile;
@@ -341,7 +323,7 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
map.put("components", models);
map.put("numberOfArtifacts", artifacts);
map.put("numberOfDeprecated", deprecated);
- String out = (String) TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
+ String out = (String)TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
return out;
} catch (Exception e) {
throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
@@ -355,7 +337,7 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
map.put("others", models);
map.put("numberOfArtifacts", artifacts);
map.put("numberOfDeprecated", deprecated);
- String out = (String) TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
+ String out = (String)TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
return out;
} catch (Exception e) {
throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
@@ -369,7 +351,7 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
map.put("dataformats", models);
map.put("numberOfArtifacts", artifacts);
map.put("numberOfDeprecated", deprecated);
- String out = (String) TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
+ String out = (String)TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
return out;
} catch (Exception e) {
throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
@@ -383,7 +365,7 @@ public class UpdateDocComponentListMojo extends AbstractMojo {
map.put("languages", models);
map.put("numberOfArtifacts", artifacts);
map.put("numberOfDeprecated", deprecated);
- String out = (String) TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
+ String out = (String)TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
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/UpdateReadmeMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateReadmeMojo.java
index bce8cb1..b3f0fde 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateReadmeMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateReadmeMojo.java
@@ -56,7 +56,8 @@ import static org.apache.camel.tooling.util.PackageHelper.writeText;
import static org.apache.camel.tooling.util.Strings.isEmpty;
/**
- * Generate or updates the component/dataformat/language/eip readme.md and .adoc files in the project root directory.
+ * Generate or updates the component/dataformat/language/eip readme.md and .adoc
+ * files in the project root directory.
*/
@Mojo(name = "update-readme", threadSafe = true)
public class UpdateReadmeMojo extends AbstractMojo {
@@ -128,7 +129,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
String title = asComponentTitle(model.getScheme(), model.getTitle());
model.setTitle(title);
- // we only want the first scheme as the alternatives do not have their own readme file
+ // we only want the first scheme as the alternatives do not
+ // have their own readme file
if (!isEmpty(model.getAlternativeSchemes())) {
String first = model.getAlternativeSchemes().split(",")[0];
if (!model.getScheme().equals(first)) {
@@ -149,7 +151,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
updated |= updateAvailableFrom(file, model.getFirstVersion());
updated |= updateComponentHeader(file, model);
- // resolvePropertyPlaceholders is an option which only make sense to use if the component has other options
+ // resolvePropertyPlaceholders is an option which only make
+ // sense to use if the component has other options
boolean hasOptions = model.getComponentOptions().stream().anyMatch(o -> !o.getName().equals("resolvePropertyPlaceholders"));
if (!hasOptions) {
model.getComponentOptions().clear();
@@ -432,14 +435,16 @@ public class UpdateReadmeMojo extends AbstractMojo {
String line = lines[i];
if (i == 1) {
- // first line is the title to make the text less noisy we use level 2
+ // first line is the title to make the text less noisy we
+ // use level 2
String newLine = "= " + title;
newLines.add(newLine);
updated = !line.equals(newLine);
continue;
}
- // use single line headers with # as level instead of the cumbersome adoc weird style
+ // use single line headers with # as level instead of the
+ // cumbersome adoc weird style
if (line.startsWith("^^^") || line.startsWith("~~~") || line.startsWith("+++")) {
String level = line.startsWith("+++") ? "===" : "==";
@@ -449,7 +454,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
newLines.set(idx, level + " " + prev);
- // okay if 2nd-prev line is a [[title]] we need to remove that too
+ // okay if 2nd-prev line is a [[title]] we need to remove
+ // that too
// so we have nice clean sub titles
idx = newLines.size() - 2;
if (idx >= 0) {
@@ -467,7 +473,6 @@ public class UpdateReadmeMojo extends AbstractMojo {
}
}
-
if (updated) {
// build the new updated text
String newText = newLines.stream().collect(Collectors.joining("\n"));
@@ -509,7 +514,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
writeText(file, updatedHeaderText);
return true;
} else {
- // so we don't have the marker, so we add it somewhere after the camel version
+ // so we don't have the marker, so we add it somewhere after the
+ // camel version
final String sinceVersion = "*Since Camel " + shortenVersion(model.getFirstVersion()) + "*";
final String before = Strings.before(loadedText, sinceVersion);
final String after = Strings.after(loadedText, sinceVersion);
@@ -557,7 +563,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
// copy over to all new lines
newLines.addAll(Arrays.asList(lines));
- // check first if it is a standard documentation file, we expect at least five lines
+ // check first if it is a standard documentation file, we expect at
+ // least five lines
if (lines.length < 5) {
return false;
}
@@ -624,7 +631,7 @@ public class UpdateReadmeMojo extends AbstractMojo {
return false;
}
- String before = Strings.before(text, "// " + kind + " options: START");
+ String before = Strings.before(text, "// " + kind + " options: START");
String after = Strings.after(text, "// " + kind + " options: END");
text = before + "// " + kind + " options: START\n" + updated + "\n// " + kind + " options: END" + after;
writeText(file, text);
@@ -718,7 +725,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
String desc = "*Required* " + option.getDescription();
option.setDescription(desc);
}
- // is the option deprecated then include that as well in the description
+ // is the option deprecated then include that as well in the
+ // description
if ("true".equals(option.getDeprecated())) {
String desc = "*Deprecated* " + option.getDescription();
option.setDescription(desc);
@@ -765,7 +773,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
String desc = "*Required* " + option.getDescription();
option.setDescription(desc);
}
- // is the option deprecated then include that as well in the description
+ // is the option deprecated then include that as well in the
+ // description
if ("true".equals(option.getDeprecated())) {
String desc = "*Deprecated* " + option.getDescription();
option.setDescription(desc);
@@ -779,7 +788,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
option.setDescription(desc);
}
}
- // separate the options in path vs parameter so we can generate two different tables
+ // separate the options in path vs parameter so we can generate two
+ // different tables
if ("path".equals(option.getKind())) {
component.addEndpointPathOption(option);
} else {
@@ -834,7 +844,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
option.setDescription(doc);
}
// lets put required in the description
- // is the option deprecated then include that as well in the description
+ // is the option deprecated then include that as well in the
+ // description
if ("true".equals(option.getDeprecated())) {
String desc = "*Deprecated* " + option.getDescription();
option.setDescription(desc);
@@ -891,7 +902,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
option.setDefaultValue(getSafeValue("defaultValue", row));
option.setDescription(getSafeValue("description", row));
- // is the option deprecated then include that as well in the description
+ // is the option deprecated then include that as well in the
+ // description
if ("true".equals(option.getDeprecated())) {
String desc = "*Deprecated* " + option.getDescription();
option.setDescription(desc);
@@ -951,7 +963,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
String desc = "*Required* " + option.getDescription();
option.setDescription(desc);
}
- // is the option deprecated then include that as well in the description
+ // is the option deprecated then include that as well in the
+ // description
if (option.isDeprecated()) {
String desc = "*Deprecated* " + option.getDescription();
option.setDescription(desc);
@@ -967,8 +980,7 @@ public class UpdateReadmeMojo extends AbstractMojo {
}
// skip option named id/description/expression/outputs
- if ("id".equals(option.getName()) || "description".equals(option.getName())
- || "expression".equals(option.getName()) || "outputs".equals(option.getName())) {
+ if ("id".equals(option.getName()) || "description".equals(option.getName()) || "expression".equals(option.getName()) || "outputs".equals(option.getName())) {
getLog().debug("Skipping option: " + option.getName());
} else {
eip.addEipOptionModel(option);
@@ -981,7 +993,7 @@ public class UpdateReadmeMojo extends AbstractMojo {
private static String evaluateTemplate(final String templateName, final Object model) throws MojoExecutionException {
try (InputStream templateStream = UpdateReadmeMojo.class.getClassLoader().getResourceAsStream(templateName)) {
String template = loadText(templateStream);
- return (String) TemplateRuntime.eval(template, model, Collections.singletonMap("util", MvelHelper.INSTANCE));
+ return (String)TemplateRuntime.eval(template, model, Collections.singletonMap("util", MvelHelper.INSTANCE));
} catch (IOException e) {
throw new MojoExecutionException("Error processing mvel template `" + templateName + "`", e);
}
@@ -996,7 +1008,8 @@ public class UpdateReadmeMojo extends AbstractMojo {
File[] files = f.listFiles();
if (files != null) {
for (File file : files) {
- // skip directories as there may be a sub .resolver directory
+ // skip directories as there may be a sub .resolver
+ // directory
if (file.isDirectory()) {
continue;
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
index deb896f..d19011f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
@@ -41,11 +41,12 @@ import static org.apache.camel.maven.packaging.ValidateHelper.validate;
/**
* Validate a Camel component analyzing if the meta-data files for
* <ul>
- * <li>components</li>
- * <li>dataformats</li>
- * <li>languages</li>
+ * <li>components</li>
+ * <li>dataformats</li>
+ * <li>languages</li>
* </ul>
- * all contains the needed meta-data such as assigned labels, documentation for each option
+ * all contains the needed meta-data such as assigned labels, documentation for
+ * each option
*/
@Mojo(name = "validate-components", threadSafe = true)
public class ValidateComponentMojo extends AbstractMojo {
@@ -57,15 +58,14 @@ public class ValidateComponentMojo extends AbstractMojo {
protected MavenProject project;
/**
- * Whether to validate if the components, data formats, and languages are properly documented and have all the needed details.
- *
+ * Whether to validate if the components, data formats, and languages are
+ * properly documented and have all the needed details.
*/
@Parameter(defaultValue = "true")
protected Boolean validate;
/**
* The output directory for generated components file
- *
*/
@Parameter(defaultValue = "${project.build.directory}/classes/")
protected File outDir;
@@ -77,8 +77,8 @@ public class ValidateComponentMojo extends AbstractMojo {
private MavenProjectHelper projectHelper;
/**
- * build context to check changed files and mark them for refresh
- * (used for m2e compatibility)
+ * build context to check changed files and mark them for refresh (used for
+ * m2e compatibility)
*/
@Component
private BuildContext buildContext;
@@ -86,9 +86,10 @@ public class ValidateComponentMojo extends AbstractMojo {
/**
* Execute goal.
*
- * @throws org.apache.maven.plugin.MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws org.apache.maven.plugin.MojoFailureException something bad happened...
+ * @throws org.apache.maven.plugin.MojoExecutionException execution of the
+ * main class or one of the threads it generated failed.
+ * @throws org.apache.maven.plugin.MojoFailureException something bad
+ * happened...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -143,7 +144,8 @@ public class ValidateComponentMojo extends AbstractMojo {
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory() && pathname.getName().equals("model")) {
- // do not check the camel-core model packages as there is no components there
+ // do not check the camel-core model packages as there is no
+ // components there
return false;
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateHelper.java
index 72c1851..7e2e605 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateHelper.java
@@ -37,7 +37,7 @@ public final class ValidateHelper {
/**
* Validates the component json file
*
- * @param file the json file
+ * @param file the json file
* @param errorDetail details to add errors
*/
public static void validate(File file, ErrorDetail errorDetail) {
@@ -79,11 +79,11 @@ public final class ValidateHelper {
syntax = true;
}
}
-
+
if (!label) {
errorDetail.setMissingLabel(true);
}
-
+
if (!description) {
errorDetail.setMissingDescription(true);
}
@@ -129,7 +129,8 @@ public final class ValidateHelper {
}
/**
- * Returns the name of the component, data format or language from the given json file
+ * Returns the name of the component, data format or language from the given
+ * json file
*/
public static String asName(File file) {
String name = file.getName();
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/GenericsUtil.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/GenericsUtil.java
index c89cf9b..4284bde 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/GenericsUtil.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/GenericsUtil.java
@@ -37,13 +37,13 @@ import java.util.Set;
* Utility classes for generic type operations.
*/
public final class GenericsUtil {
-
+
/*
* Private constructor
*/
private GenericsUtil() {
}
-
+
public static boolean satisfiesDependency(boolean isDelegateOrEvent, boolean isProducer, Type injectionPointType, Type beanType) {
if (beanType instanceof TypeVariable || beanType instanceof WildcardType || beanType instanceof GenericArrayType) {
return isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType, beanType);
@@ -509,7 +509,7 @@ public final class GenericsUtil {
for (int i = 0; i < types.length; i++) {
final Type type = resolveType(types[i], actualType, seen);
if (type != null) { // means a stackoverflow was avoided, just keep
- // what we have
+ // what we have
resolvedTypeArguments[i] = type;
}
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipModel.java
index 5aadf2f..99d7e5f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipModel.java
@@ -126,4 +126,3 @@ public class EipModel {
}
}
-
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipOptionModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipOptionModel.java
index 5e2ee91..970bc3a0 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipOptionModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EipOptionModel.java
@@ -185,4 +185,3 @@ public class EipOptionModel {
}
}
-
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/SpringBootAutoConfigureOptionModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/SpringBootAutoConfigureOptionModel.java
index d07f627..135847c 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/SpringBootAutoConfigureOptionModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/SpringBootAutoConfigureOptionModel.java
@@ -90,5 +90,4 @@ public class SpringBootAutoConfigureOptionModel {
return text;
}
-
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MvelHelperTest.java b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MvelHelperTest.java
index d3a76dc..e64703f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MvelHelperTest.java
+++ b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/MvelHelperTest.java
@@ -54,25 +54,18 @@ public class MvelHelperTest {
}
static Stream<Arguments> dollarEscapeCases() {
- return Stream.of(
- arguments("$", "\\$"),
- arguments("some ${expression} here", "some \\$\\{expression\\} here"));
+ return Stream.of(arguments("$", "\\$"), arguments("some ${expression} here", "some \\$\\{expression\\} here"));
}
static Stream<Arguments> curlyBracketEscapeCases() {
- return Stream.of(
- arguments("some {expression} here", "some \\{expression\\} here"));
+ return Stream.of(arguments("some {expression} here", "some \\{expression\\} here"));
}
static Stream<Arguments> urlEscapeCases() {
- return Stream.of(
- arguments("http", "http"),
- arguments("some ${expression} here", "some \\$\\{expression\\} here"),
- arguments("http://example.com", "\\http://example.com"),
- arguments("some http://example.com here", "some \\http://example.com here"),
- arguments("https://example.com", "\\https://example.com"),
- arguments("ftp://example.com", "\\ftp://example.com"),
- arguments("Sets the POST URL for zipkin's <a href=\"http://zipkin.io/zipkin-api/#/\">v2 api</a>, usually \"http://zipkinhost:9411/api/v2/spans\"",
- "Sets the POST URL for zipkin's <a href=\"http://zipkin.io/zipkin-api/#/\">v2 api</a>, usually \"\\http://zipkinhost:9411/api/v2/spans\""));
+ return Stream.of(arguments("http", "http"), arguments("some ${expression} here", "some \\$\\{expression\\} here"), arguments("http://example.com", "\\http://example.com"),
+ arguments("some http://example.com here", "some \\http://example.com here"), arguments("https://example.com", "\\https://example.com"),
+ arguments("ftp://example.com", "\\ftp://example.com"),
+ arguments("Sets the POST URL for zipkin's <a href=\"http://zipkin.io/zipkin-api/#/\">v2 api</a>, usually \"http://zipkinhost:9411/api/v2/spans\"",
+ "Sets the POST URL for zipkin's <a href=\"http://zipkin.io/zipkin-api/#/\">v2 api</a>, usually \"\\http://zipkinhost:9411/api/v2/spans\""));
}
}
diff --git a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/model/StringHelperTest.java b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/model/StringHelperTest.java
index 560f91f..97db8c1 100644
--- a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/model/StringHelperTest.java
+++ b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/model/StringHelperTest.java
@@ -29,17 +29,10 @@ import static org.junit.jupiter.params.provider.Arguments.arguments;
public class StringHelperTest {
static Stream<Arguments> getClassShortNameTypeVarations() {
- return Stream.of(
- arguments("String", "String"),
- arguments("String", "java.lang.String"),
- arguments("List", "List<String>"),
- arguments("List", "java.util.List<String>"),
- arguments("List", "List<java.lang.String>"),
- arguments("List", "java.util.List.List<org.apache.camel.Exchange>"),
- arguments("List", "java.util.List<Map<String,Integer>>"),
- arguments("List", "java.util.List<Map<java.lang.String,Integer>>"),
- arguments("List", "java.util.List<Map<String,java.lang.Integer>>"),
- arguments("List", "java.util.List<Map<java.lang.String,java.lang.Integer>>"),
+ return Stream.of(arguments("String", "String"), arguments("String", "java.lang.String"), arguments("List", "List<String>"), arguments("List", "java.util.List<String>"),
+ arguments("List", "List<java.lang.String>"), arguments("List", "java.util.List.List<org.apache.camel.Exchange>"),
+ arguments("List", "java.util.List<Map<String,Integer>>"), arguments("List", "java.util.List<Map<java.lang.String,Integer>>"),
+ arguments("List", "java.util.List<Map<String,java.lang.Integer>>"), arguments("List", "java.util.List<Map<java.lang.String,java.lang.Integer>>"),
arguments("List", "java.util.List<java.util.Map<java.lang.String,java.lang.Integer>>"));
}