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 2015/01/13 18:04:31 UTC
[05/13] camel git commit: CAMEL-8232: Camel Toolbox - Include
documentation about data formats
CAMEL-8232: Camel Toolbox - Include documentation about data formats
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/109285c8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/109285c8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/109285c8
Branch: refs/heads/master
Commit: 109285c86085cb553426f67fdb3b41576dd9d3da
Parents: c09d1d4
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jan 13 10:18:55 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jan 13 17:33:28 2015 +0100
----------------------------------------------------------------------
camel-core/pom.xml | 2 +
components/pom.xml | 2 +
.../maven/packaging/PackageComponentMojo.java | 131 +++++++++++++++++++
.../maven/packaging/PackageDataFormatMojo.java | 131 +++++++++++++++++++
.../camel/maven/packaging/PackageMojo.java | 131 -------------------
.../META-INF/m2e/lifecycle-mapping-metadata.xml | 1 +
6 files changed, 267 insertions(+), 131 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/109285c8/camel-core/pom.xml
----------------------------------------------------------------------
diff --git a/camel-core/pom.xml b/camel-core/pom.xml
index 7a3b86b..8540900 100644
--- a/camel-core/pom.xml
+++ b/camel-core/pom.xml
@@ -193,6 +193,7 @@
<versionRange>${project.version}</versionRange>
<goals>
<goal>generate-components-list</goal>
+ <goal>generate-dataformats-list</goal>
</goals>
</pluginExecutionFilter>
<action>
@@ -281,6 +282,7 @@
<id>components</id>
<goals>
<goal>generate-components-list</goal>
+ <goal>generate-dataformats-list</goal>
</goals>
<phase>generate-resources</phase>
</execution>
http://git-wip-us.apache.org/repos/asf/camel/blob/109285c8/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 5615d40..ffdca6f 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -247,6 +247,7 @@
<versionRange>${project.version}</versionRange>
<goals>
<goal>generate-components-list</goal>
+ <goal>generate-dataformats-list</goal>
</goals>
</pluginExecutionFilter>
<action>
@@ -268,6 +269,7 @@
<execution>
<goals>
<goal>generate-components-list</goal>
+ <goal>generate-dataformats-list</goal>
</goals>
<phase>generate-resources</phase>
</execution>
http://git-wip-us.apache.org/repos/asf/camel/blob/109285c8/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..702c674
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.packaging;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+
+/**
+ * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ *
+ * @goal generate-components-list
+ * @execute phase="generate-resources"
+ */
+public class PackageComponentMojo extends AbstractMojo {
+
+ /**
+ * The maven project.
+ *
+ * @parameter property="project"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * The output directory for generated components file
+ *
+ * @parameter default-value="${project.build.directory}/generated/camel/components"
+ */
+ protected File outDir;
+
+ /**
+ * Maven ProjectHelper.
+ *
+ * @component
+ * @readonly
+ */
+ private MavenProjectHelper projectHelper;
+
+ /**
+ * Execute goal.
+ *
+ * @throws MojoExecutionException execution of the main class or one of the
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ File camelMetaDir = new File(outDir, "META-INF/services/org/apache/camel/");
+
+ StringBuilder buffer = new StringBuilder();
+ int count = 0;
+ for (Resource r : project.getBuild().getResources()) {
+ File f = new File(r.getDirectory());
+ if (!f.exists()) {
+ f = new File(project.getBasedir(), r.getDirectory());
+ }
+ f = new File(f, "META-INF/services/org/apache/camel/component");
+
+ if (f.exists() && f.isDirectory()) {
+ File[] files = f.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ String name = file.getName();
+ if (name.charAt(0) != '.') {
+ count++;
+ if (buffer.length() > 0) {
+ buffer.append(" ");
+ }
+ buffer.append(name);
+ }
+ }
+ }
+ }
+ }
+
+ if (count > 0) {
+ Properties properties = new Properties();
+ String names = buffer.toString();
+ properties.put("components", names);
+ properties.put("groupId", project.getGroupId());
+ properties.put("artifactId", project.getArtifactId());
+ properties.put("version", project.getVersion());
+ properties.put("projectName", project.getName());
+ properties.put("projectDescription", project.getDescription());
+
+ camelMetaDir.mkdirs();
+ File outFile = new File(camelMetaDir, "component.properties");
+ try {
+ properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin");
+ getLog().info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "components: " : "component: ") + names);
+
+ if (projectHelper != null) {
+ List<String> includes = new ArrayList<String>();
+ includes.add("**/component.properties");
+ projectHelper.addResource(this.project, outDir.getPath(), includes, new ArrayList<String>());
+ projectHelper.attachArtifact(this.project, "properties", "camelComponent", outFile);
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
+ }
+ } else {
+ getLog().debug("No META-INF/services/org/apache/camel/component directory found. Are you sure you have created a Camel component?");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/109285c8/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..38b3bf3
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.packaging;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+
+/**
+ * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ *
+ * @goal generate-dataformats-list
+ * @execute phase="generate-resources"
+ */
+public class PackageDataFormatMojo extends AbstractMojo {
+
+ /**
+ * The maven project.
+ *
+ * @parameter property="project"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * The output directory for generated dataformats file
+ *
+ * @parameter default-value="${project.build.directory}/generated/camel/dataformats"
+ */
+ protected File outDir;
+
+ /**
+ * Maven ProjectHelper.
+ *
+ * @component
+ * @readonly
+ */
+ private MavenProjectHelper projectHelper;
+
+ /**
+ * 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...
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ File camelMetaDir = new File(outDir, "META-INF/services/org/apache/camel/");
+
+ StringBuilder buffer = new StringBuilder();
+ int count = 0;
+ for (Resource r : project.getBuild().getResources()) {
+ File f = new File(r.getDirectory());
+ if (!f.exists()) {
+ f = new File(project.getBasedir(), r.getDirectory());
+ }
+ f = new File(f, "META-INF/services/org/apache/camel/dataformat");
+
+ if (f.exists() && f.isDirectory()) {
+ File[] files = f.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ String name = file.getName();
+ if (name.charAt(0) != '.') {
+ count++;
+ if (buffer.length() > 0) {
+ buffer.append(" ");
+ }
+ buffer.append(name);
+ }
+ }
+ }
+ }
+ }
+
+ if (count > 0) {
+ Properties properties = new Properties();
+ String names = buffer.toString();
+ properties.put("dataFormats", names);
+ properties.put("groupId", project.getGroupId());
+ properties.put("artifactId", project.getArtifactId());
+ properties.put("version", project.getVersion());
+ properties.put("projectName", project.getName());
+ properties.put("projectDescription", project.getDescription());
+
+ camelMetaDir.mkdirs();
+ File outFile = new File(camelMetaDir, "dataformat.properties");
+ try {
+ properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin");
+ getLog().info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "dataformats: " : "dataformat: ") + names);
+
+ if (projectHelper != null) {
+ List<String> includes = new ArrayList<String>();
+ includes.add("**/dataformat.properties");
+ projectHelper.addResource(this.project, outDir.getPath(), includes, new ArrayList<String>());
+ projectHelper.attachArtifact(this.project, "properties", "camelDataFormat", outFile);
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
+ }
+ } else {
+ getLog().debug("No META-INF/services/org/apache/camel/dataformat directory found. Are you sure you have created a Camel data format?");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/109285c8/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageMojo.java
deleted file mode 100644
index 6772d8f..0000000
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageMojo.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.maven.packaging;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
-
-/**
- * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
- *
- * @goal generate-components-list
- * @execute phase="generate-resources"
- */
-public class PackageMojo extends AbstractMojo {
-
- /**
- * The maven project.
- *
- * @parameter property="project"
- * @required
- * @readonly
- */
- protected MavenProject project;
-
- /**
- * The output directory for generated components file
- *
- * @parameter default-value="${project.build.directory}/generated/camel/components"
- */
- protected File outDir;
-
- /**
- * Maven ProjectHelper.
- *
- * @component
- * @readonly
- */
- private MavenProjectHelper projectHelper;
-
- /**
- * Execute goal.
- *
- * @throws MojoExecutionException execution of the main class or one of the
- * threads it generated failed.
- * @throws MojoFailureException something bad happened...
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
- File camelMetaDir = new File(outDir, "META-INF/services/org/apache/camel/");
-
- StringBuilder buffer = new StringBuilder();
- int count = 0;
- for (Resource r : project.getBuild().getResources()) {
- File f = new File(r.getDirectory());
- if (!f.exists()) {
- f = new File(project.getBasedir(), r.getDirectory());
- }
- f = new File(f, "META-INF/services/org/apache/camel/component");
-
- if (f.exists() && f.isDirectory()) {
- File[] files = f.listFiles();
- if (files != null) {
- for (File file : files) {
- String name = file.getName();
- if (name.charAt(0) != '.') {
- count++;
- if (buffer.length() > 0) {
- buffer.append(" ");
- }
- buffer.append(name);
- }
- }
- }
- }
- }
-
- if (count > 0) {
- Properties properties = new Properties();
- String names = buffer.toString();
- properties.put("components", names);
- properties.put("groupId", project.getGroupId());
- properties.put("artifactId", project.getArtifactId());
- properties.put("version", project.getVersion());
- properties.put("projectName", project.getName());
- properties.put("projectDescription", project.getDescription());
-
- camelMetaDir.mkdirs();
- File outFile = new File(camelMetaDir, "component.properties");
- try {
- properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin");
- getLog().info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "components: " : "component: ") + names);
-
- if (projectHelper != null) {
- List<String> includes = new ArrayList<String>();
- includes.add("**/component.properties");
- projectHelper.addResource(this.project, outDir.getPath(), includes, new ArrayList<String>());
- projectHelper.attachArtifact(this.project, "properties", "camelComponent", outFile);
- }
- } catch (IOException e) {
- throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
- }
- } else {
- getLog().debug("No META-INF/services/org/apache/camel/component directory found. Are you sure you have created a Camel component?");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/109285c8/tooling/maven/camel-package-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/tooling/maven/camel-package-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
index 56f2169..ca34605 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
+++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -20,6 +20,7 @@
<pluginExecutionFilter>
<goals>
<goal>generate-components-list</goal>
+ <goal>generate-dataformats-list</goal>
</goals>
</pluginExecutionFilter>
<action>