You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/01/16 08:48:29 UTC
[camel] branch master updated (7d539e4 -> a270d7d)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 7d539e4 Fixed CS for Camel-Crypto-cms
new 7f0b35a CAMEL-13067: apt compiler plugin fixed to include component level metadata again
new a270d7d CAMEL-13067: The maven plugin no longer needs to enrich with class javatype as the apt plugin does that correctly again.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../tools/apt/EndpointAnnotationProcessor.java | 20 ++++++-
.../maven/packaging/PackageComponentMojo.java | 64 ++++++++--------------
2 files changed, 42 insertions(+), 42 deletions(-)
[camel] 02/02: CAMEL-13067: The maven plugin no longer needs to
enrich with class javatype as the apt plugin does that correctly again.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a270d7d96236716b25643dbdd7e5d3aa1fed9167
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 16 09:40:08 2019 +0100
CAMEL-13067: The maven plugin no longer needs to enrich with class javatype as the apt plugin does that correctly again.
---
.../maven/packaging/PackageComponentMojo.java | 64 ++++++++--------------
1 file changed, 24 insertions(+), 40 deletions(-)
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 de29a45..84278d5 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
@@ -22,8 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@@ -107,8 +106,7 @@ public class PackageComponentMojo extends AbstractMojo {
StringBuilder buffer = new StringBuilder();
int count = 0;
- Map<String, String> components = new LinkedHashMap<>();
-
+ Set<String> components = new HashSet<>();
File f = new File(project.getBasedir(), "target/classes");
f = new File(f, "META-INF/services/org/apache/camel/component");
if (f.exists() && f.isDirectory()) {
@@ -126,20 +124,7 @@ public class PackageComponentMojo extends AbstractMojo {
buffer.append(" ");
}
buffer.append(name);
- }
-
- // grab the java class name for the discovered component
- try {
- Properties prop = new Properties();
- prop.load(new FileInputStream(file));
-
- String javaType = prop.getProperty("class");
-
- components.put(name, javaType);
- log.debug("Discovered component: " + name + " with class: " + javaType);
-
- } catch (IOException e) {
- throw new MojoExecutionException("Failed to load file " + file + ". Reason: " + e, e);
+ components.add(file.getName());
}
}
}
@@ -204,33 +189,32 @@ public class PackageComponentMojo extends AbstractMojo {
return count;
}
- private static void enrichComponentJsonFiles(Log log, MavenProject project, File buildDir, Map<String, String> components) throws MojoExecutionException {
+ private static void enrichComponentJsonFiles(Log log, MavenProject project, File buildDir, Set<String> components) throws MojoExecutionException {
final Set<File> files = PackageHelper.findJsonFiles(buildDir, p -> p.isDirectory() || p.getName().endsWith(".json"));
for (File file : files) {
- // name without .json
- String shortName = file.getName().substring(0, file.getName().length() - 5);
- String javaType = components.getOrDefault(shortName, "");
- log.debug("Enriching file: " + file);
+ // clip the .json suffix
+ String name = file.getName().substring(0, file.getName().length() - 5);
+ if (components.contains(name)) {
+ log.debug("Enriching component: " + name);
+ try {
+ String text = loadText(new FileInputStream(file));
+ text = text.replace("@@@DESCRIPTION@@@", project.getDescription());
+ text = text.replace("@@@GROUPID@@@", project.getGroupId());
+ 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
+ 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
+ text = text.replaceFirst(" {4}\"deprecated\": false,", " \"deprecated\": true,");
+ }
- try {
- String text = loadText(new FileInputStream(file));
- text = text.replace("@@@JAVATYPE@@@", javaType);
- text = text.replace("@@@DESCRIPTION@@@", project.getDescription());
- text = text.replace("@@@GROUPID@@@", project.getGroupId());
- 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
- 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
- text = text.replaceFirst(" {4}\"deprecated\": false,", " \"deprecated\": true,");
+ writeText(file, text);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Failed to update file " + file + ". Reason: " + e, e);
}
-
- writeText(file, text);
- } catch (IOException e) {
- throw new MojoExecutionException("Failed to update file " + file + ". Reason: " + e, e);
}
}
}
[camel] 01/02: CAMEL-13067: apt compiler plugin fixed to include
component level metadata again
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7f0b35a1e0dbbb088c0ce32b6094e470b5013549
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 16 09:27:35 2019 +0100
CAMEL-13067: apt compiler plugin fixed to include component level metadata again
---
.../camel/tools/apt/EndpointAnnotationProcessor.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index 5d41446..6f1714c 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -44,6 +44,7 @@ import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
+import org.apache.camel.spi.annotations.Component;
import org.apache.camel.tools.apt.helper.CollectionStringBuffer;
import org.apache.camel.tools.apt.helper.EndpointHelper;
import org.apache.camel.tools.apt.helper.JsonSchemaHelper;
@@ -57,7 +58,6 @@ import static org.apache.camel.tools.apt.AnnotationProcessorHelper.findFieldElem
import static org.apache.camel.tools.apt.AnnotationProcessorHelper.findJavaDoc;
import static org.apache.camel.tools.apt.AnnotationProcessorHelper.findTypeElement;
import static org.apache.camel.tools.apt.AnnotationProcessorHelper.implementsInterface;
-import static org.apache.camel.tools.apt.AnnotationProcessorHelper.loadResource;
import static org.apache.camel.tools.apt.AnnotationProcessorHelper.processFile;
import static org.apache.camel.tools.apt.helper.JsonSchemaHelper.sanitizeDescription;
import static org.apache.camel.tools.apt.helper.Strings.canonicalClassName;
@@ -352,6 +352,20 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso
model.setFirstVersion(firstVersion);
}
+ // get the java type class name via the @Component annotation from its component class
+ Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(Component.class);
+ if (elements != null) {
+ for (Element e : elements) {
+ Component comp = e.getAnnotation(Component.class);
+ if (scheme.equals(comp.value()) && e.getKind() == ElementKind.CLASS) {
+ TypeElement te = (TypeElement) e;
+ String name = te.getQualifiedName().toString();
+ model.setJavaType(name);
+ break;
+ }
+ }
+ }
+
// we can mark a component as deprecated by using the annotation
boolean deprecated = endpointClassElement.getAnnotation(Deprecated.class) != null;
model.setDeprecated(deprecated);
@@ -362,7 +376,9 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso
model.setDeprecationNote(deprecationNote);
// these information is not available at compile time and we enrich these later during the camel-package-maven-plugin
- model.setJavaType("@@@JAVATYPE@@@");
+ if (model.getJavaType() == null) {
+ model.setJavaType("@@@JAVATYPE@@@");
+ }
model.setDescription("@@@DESCRIPTION@@@");
model.setGroupId("@@@GROUPID@@@");
model.setArtifactId("@@@ARTIFACTID@@@");