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/06/28 11:35:52 UTC
[camel] 02/02: CAMEL-13698: Fixed camel archetype catalog and only
attach the catalog to the archetypes pom.
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 495bb73c1a5e8c0cc2252f536617a71a3f9bc655
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 28 13:35:25 2019 +0200
CAMEL-13698: Fixed camel archetype catalog and only attach the catalog to the archetypes pom.
---
.../META-INF/maven/archetype-metadata.xml | 3 +++
.../src/main/resources/archetype-resources/pom.xml | 27 ++++++++++++-------
.../src/main/resources/application.properties | 3 ++-
parent/pom.xml | 1 +
.../packaging/PackageArchetypeCatalogMojo.java | 31 +++++++++++-----------
5 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/archetypes/camel-archetype-main/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/archetypes/camel-archetype-main/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
index f548a55..06bf4b2 100644
--- a/archetypes/camel-archetype-main/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
+++ b/archetypes/camel-archetype-main/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -24,6 +24,9 @@
<requiredProperty key="camel-version">
<defaultValue>${project.version}</defaultValue>
</requiredProperty>
+ <requiredProperty key="logback-version">
+ <defaultValue>${logback-version}</defaultValue>
+ </requiredProperty>
<requiredProperty key="maven-compiler-plugin-version">
<defaultValue>${maven-compiler-plugin-version}</defaultValue>
</requiredProperty>
diff --git a/archetypes/camel-archetype-main/src/main/resources/archetype-resources/pom.xml b/archetypes/camel-archetype-main/src/main/resources/archetype-resources/pom.xml
index 98f724d..dec0e46 100644
--- a/archetypes/camel-archetype-main/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/camel-archetype-main/src/main/resources/archetype-resources/pom.xml
@@ -47,32 +47,41 @@
<dependencies>
+ <!-- lets use the minimal camel-core -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core-engine</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-main</artifactId>
</dependency>
- <!-- we use these components -->
+ <!-- where we need to pick which components we use (also core components) -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-bean</artifactId>
</dependency>
-
- <!-- logging -->
<dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>runtime</scope>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-log</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-timer</artifactId>
</dependency>
+
+ <!-- logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
- <version>1.2.3</version>
+ <version>${logback-version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
+ <version>${logback-version}</version>
</dependency>
<!-- testing -->
@@ -112,7 +121,7 @@
<version>${camel-version}</version>
<configuration>
<logClasspath>true</logClasspath>
- <mainClass>${package}.MainApp</mainClass>
+ <mainClass>${package}.MyApplication</mainClass>
</configuration>
</plugin>
diff --git a/archetypes/camel-archetype-main/src/main/resources/archetype-resources/src/main/resources/application.properties b/archetypes/camel-archetype-main/src/main/resources/archetype-resources/src/main/resources/application.properties
index f3d65e0..cb2d0a3 100644
--- a/archetypes/camel-archetype-main/src/main/resources/archetype-resources/src/main/resources/application.properties
+++ b/archetypes/camel-archetype-main/src/main/resources/archetype-resources/src/main/resources/application.properties
@@ -25,7 +25,7 @@ camel.main.jmx-enabled = false
# to configure the camel timer component
# here we can configure the options on the component level (and we can use dash-naming-style)
-camel.component.quartz2.start-delayed-seconds = 3
+### camel.component.quartz2.start-delayed-seconds = 3
# to configure Hystrix EIP (global and you need to add camel-hystrix to the classpath)
### camel.hystrix.group-key=myGroup
@@ -44,4 +44,5 @@ myPeriod = 3s
# application properties
hi = Hello
+bye = Goodbye
diff --git a/parent/pom.xml b/parent/pom.xml
index dad458d..2f1c0b7 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -455,6 +455,7 @@
<lettuce-version>5.1.0.RELEASE</lettuce-version>
<log4j-version>1.2.17</log4j-version>
<log4j2-version>2.11.2</log4j2-version>
+ <logback-version>1.2.3</logback-version>
<lucene3-bundle-version>3.6.0_1</lucene3-bundle-version>
<lucene3-version>3.6.0</lucene3-version>
<lucene-bundle-version>7.6.0_1</lucene-bundle-version>
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 ca513e2..c749b62 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
@@ -34,6 +34,7 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
+import static org.apache.camel.maven.packaging.PackageHelper.findCamelDirectory;
import static org.apache.camel.maven.packaging.StringHelper.between;
/**
@@ -49,18 +50,12 @@ public class PackageArchetypeCatalogMojo extends AbstractMojo {
protected MavenProject project;
/**
- * The output directory for generated components file
+ * The output directory for generated archetypes
*/
@Parameter(defaultValue = "${project.build.directory}/classes/")
protected File outDir;
/**
- * The build directory
- */
- @Parameter(defaultValue = "${project.build.directory}")
- protected File projectBuildDir;
-
- /**
* Maven ProjectHelper.
*/
@Component
@@ -74,20 +69,26 @@ public class PackageArchetypeCatalogMojo extends AbstractMojo {
* @throws org.apache.maven.plugin.MojoFailureException something bad happened...
*/
public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- generateArchetypeCatalog(getLog(), project, projectHelper, projectBuildDir, outDir);
- } catch (IOException e) {
- throw new MojoFailureException("Error generating archetype catalog due " + e.getMessage(), e);
+ // only generate this for the root pom
+ if ("pom".equals(project.getModel().getPackaging())) {
+ try {
+ generateArchetypeCatalog(getLog(), project, projectHelper, outDir);
+ } catch (IOException e) {
+ throw new MojoFailureException("Error generating archetype catalog due " + e.getMessage(), e);
+ }
}
}
- public static void generateArchetypeCatalog(Log log, MavenProject project, MavenProjectHelper projectHelper, File projectBuildDir, File outDir) throws MojoExecutionException, IOException {
+ public static void generateArchetypeCatalog(Log log, MavenProject project, MavenProjectHelper projectHelper, File outDir) throws MojoExecutionException, IOException {
- File rootDir = projectBuildDir.getParentFile();
- log.info("Scanning for Camel Maven Archetypes from root directory " + rootDir);
+ File archetypes = findCamelDirectory(project.getBasedir(), "archetypes");
+ if (archetypes == null || !archetypes.exists()) {
+ throw new MojoExecutionException("Cannot find directory: archetypes");
+ }
+ log.info("Scanning for Camel Maven Archetypes from directory: " + archetypes);
// find all archetypes which are in the parent dir of the build dir
- File[] dirs = rootDir.listFiles(new FileFilter() {
+ File[] dirs = archetypes.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().startsWith("camel-archetype") && pathname.isDirectory();