This is an automated email from the ASF dual-hosted git repository.
oalsafi 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 c0ff7bc CAMEL-14886: Add camel-component-maven-plugin (#3890)
c0ff7bc is described below
commit c0ff7bca23b3346009b20b2b087ee5147df973db
Author: Omar Al-Safi <[email protected]>
AuthorDate: Fri Jun 5 16:00:33 2020 +0200
CAMEL-14886: Add camel-component-maven-plugin (#3890)
* CAMEL-14886: Initial maven plugin
* CAMEL-14886: Working maven plugin
* CAMEL-14886: Polishing
* CAMEL-14886: Add camel-component maven plugin to the archetypes
---
.../__artifactId__-component/pom.xml | 4 +-
.../src/main/resources/archetype-resources/pom.xml | 4 +-
.../META-INF/maven/archetype-metadata.xml | 4 +-
.../src/main/resources/archetype-resources/pom.xml | 5 +-
tooling/maven/camel-component-maven-plugin/pom.xml | 73 +++++++++++++++++++
.../maven/component/GenerateComponentMojo.java | 81 ++++++++++++++++++++++
tooling/maven/pom.xml | 1 +
7 files changed, 164 insertions(+), 8 deletions(-)
diff --git
a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
index f23f070..0c40739 100644
---
a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
+++
b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -185,13 +185,13 @@
<!-- generate camel meta-data -->
<plugin>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-package-maven-plugin</artifactId>
+ <artifactId>camel-component-maven-plugin</artifactId>
<version>${camelVersion}</version>
<executions>
<execution>
<id>generate</id>
<goals>
- <goal>generate-component</goal>
+ <goal>generate</goal>
</goals>
<phase>process-classes</phase>
</execution>
diff --git
a/archetypes/camel-archetype-component/src/main/resources/archetype-resources/pom.xml
b/archetypes/camel-archetype-component/src/main/resources/archetype-resources/pom.xml
index 4a58e74..185a5f5 100644
---
a/archetypes/camel-archetype-component/src/main/resources/archetype-resources/pom.xml
+++
b/archetypes/camel-archetype-component/src/main/resources/archetype-resources/pom.xml
@@ -95,13 +95,13 @@
<!-- generate camel meta-data -->
<plugin>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-package-maven-plugin</artifactId>
+ <artifactId>camel-component-maven-plugin</artifactId>
<version>${camel-version}</version>
<executions>
<execution>
<id>generate</id>
<goals>
- <goal>generate-component</goal>
+ <goal>generate</goal>
</goals>
<phase>process-classes</phase>
</execution>
diff --git
a/archetypes/camel-archetype-dataformat/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
b/archetypes/camel-archetype-dataformat/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
index a08c171..e89a350 100644
---
a/archetypes/camel-archetype-dataformat/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
+++
b/archetypes/camel-archetype-dataformat/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -26,8 +26,8 @@
<requiredProperty key="camel-version">
<defaultValue>${project.version}</defaultValue>
</requiredProperty>
- <requiredProperty key="log4j-version">
- <defaultValue>${log4j-version}</defaultValue>
+ <requiredProperty key="log4j2-version">
+ <defaultValue>${log4j2-version}</defaultValue>
</requiredProperty>
<requiredProperty key="maven-compiler-plugin-version">
<defaultValue>${maven-compiler-plugin-version}</defaultValue>
diff --git
a/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/pom.xml
b/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/pom.xml
index 3275e81..ea961e1 100644
---
a/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/pom.xml
+++
b/archetypes/camel-archetype-dataformat/src/main/resources/archetype-resources/pom.xml
@@ -55,6 +55,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
+ <version>${log4j2-version}</version>
<scope>test</scope>
</dependency>
@@ -93,13 +94,13 @@
<!-- generate camel meta-data -->
<plugin>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-package-maven-plugin</artifactId>
+ <artifactId>camel-component-maven-plugin</artifactId>
<version>${camel-version}</version>
<executions>
<execution>
<id>generate</id>
<goals>
- <goal>generate-component</goal>
+ <goal>generate</goal>
</goals>
<phase>process-classes</phase>
</execution>
diff --git a/tooling/maven/camel-component-maven-plugin/pom.xml
b/tooling/maven/camel-component-maven-plugin/pom.xml
new file mode 100644
index 0000000..2796964
--- /dev/null
+++ b/tooling/maven/camel-component-maven-plugin/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>3.4.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-component-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+
+ <name>Camel :: Maven Plugins :: Camel Maven Component</name>
+ <description>Maven plugin to help package 3rd party component developers
to generate all needed metadata files needed for Camel</description>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>tooling-parent</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-package-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/tooling/maven/camel-component-maven-plugin/src/main/java/org/apache/camel/maven/component/GenerateComponentMojo.java
b/tooling/maven/camel-component-maven-plugin/src/main/java/org/apache/camel/maven/component/GenerateComponentMojo.java
new file mode 100644
index 0000000..9f14277
--- /dev/null
+++
b/tooling/maven/camel-component-maven-plugin/src/main/java/org/apache/camel/maven/component/GenerateComponentMojo.java
@@ -0,0 +1,81 @@
+/*
+ * 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.component;
+
+import org.apache.camel.maven.packaging.AbstractGenerateMojo;
+import org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo;
+import org.apache.camel.maven.packaging.GenerateConfigurerMojo;
+import org.apache.camel.maven.packaging.PackageJandexMojo;
+import org.apache.camel.maven.packaging.PrepareComponentMojo;
+import org.apache.camel.maven.packaging.SpiGeneratorMojo;
+import org.apache.camel.maven.packaging.TypeConverterLoaderGeneratorMojo;
+import org.apache.camel.maven.packaging.ValidateComponentMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.sonatype.plexus.build.incremental.BuildContext;
+
+/**
+ * To be used by 3rd party Camel component developers to generate metadata.
+ */
+@Mojo(name = "generate", threadSafe = true, requiresDependencyResolution =
ResolutionScope.COMPILE_PLUS_RUNTIME,
+ defaultPhase = LifecyclePhase.PROCESS_CLASSES)
+public class GenerateComponentMojo extends AbstractGenerateMojo {
+
+ @Parameter(property = "project", required = true, readonly = true)
+ protected MavenProject currentProject;
+ @Component
+ protected MavenProjectHelper currentProjectHelper;
+ @Component
+ protected BuildContext currentBuildContext;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ this.project = currentProject;
+ this.projectHelper = currentProjectHelper;
+ this.buildContext = currentBuildContext;
+
+ super.execute();
+ }
+
+ @Override
+ protected void doExecute() throws MojoFailureException,
MojoExecutionException {
+ // do not sync pom file for this goal as we are standalone
+ project.setContextValue("syncPomFile", "false");
+
+ // jandex
+ invoke(PackageJandexMojo.class);
+ // generate-type-converter-loader
+ invoke(TypeConverterLoaderGeneratorMojo.class);
+ // generate-spi
+ invoke(SpiGeneratorMojo.class);
+ // generate-configurer
+ invoke(GenerateConfigurerMojo.class);
+ // generate-endpoint-schema
+ invoke(EndpointSchemaGeneratorMojo.class);
+ // prepare-components
+ invoke(PrepareComponentMojo.class);
+ // validate-components
+ invoke(ValidateComponentMojo.class);
+ }
+}
diff --git a/tooling/maven/pom.xml b/tooling/maven/pom.xml
index c93f91a..3cc3b0e 100644
--- a/tooling/maven/pom.xml
+++ b/tooling/maven/pom.xml
@@ -44,6 +44,7 @@
<module>camel-javadoc-plugin</module>
<module>camel-resources-plugin</module>
<module>sync-properties-maven-plugin</module>
+ <module>camel-component-maven-plugin</module>
</modules>
<!-- Apply to children. -->