You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/03/11 09:59:54 UTC
[camel-quarkus] 03/03: Flatten the catalog module hierarchy
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 792a21bf22391fe9486edc9862bc135b3b477f63
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Tue Mar 10 23:50:50 2020 +0100
Flatten the catalog module hierarchy
---
catalog/camel-quarkus-catalog/pom.xml | 97 ----------------------
catalog/pom.xml | 82 ++++++++++++++++--
.../catalog/quarkus/QuarkusRuntimeProvider.java | 0
.../src/main/resources/META-INF/LICENSE.txt | 0
.../src/main/resources/META-INF/NOTICE.txt | 0
.../quarkus/QuarkusRuntimeProviderTest.java | 0
.../quarkus/maven/PrepareCatalogQuarkusMojo.java | 93 +++++++++++----------
7 files changed, 124 insertions(+), 148 deletions(-)
diff --git a/catalog/camel-quarkus-catalog/pom.xml b/catalog/camel-quarkus-catalog/pom.xml
deleted file mode 100644
index eb6e3d0..0000000
--- a/catalog/camel-quarkus-catalog/pom.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<?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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-build-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <relativePath>../../poms/build-parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>camel-catalog-quarkus</artifactId>
- <packaging>jar</packaging>
- <name>Camel Quarkus :: Camel Quarkus Catalog</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-catalog</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.slf4j</groupId>
- <artifactId>slf4j-jboss-logging</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
-
- <!-- generate and include all components in the catalog -->
- <plugin>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-package-maven-plugin</artifactId>
- <version>${project.version}</version>
- <dependencies>
- <!-- include camel-catalog on classpath -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-catalog</artifactId>
- <version>${camel.version}</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <!-- prepare the catalog and update doc files, etc. -->
- <goals>
- <goal>prepare-catalog-quarkus</goal>
- <goal>update-doc-extensions-list</goal>
- </goals>
- <phase>process-resources</phase>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
-
- </build>
-
-</project>
diff --git a/catalog/pom.xml b/catalog/pom.xml
index 41e0507..23f873f 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -17,22 +17,86 @@
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">
-
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-parent</artifactId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>../poms/build-parent/pom.xml</relativePath>
</parent>
- <artifactId>catalog</artifactId>
- <packaging>pom</packaging>
-
+ <artifactId>camel-quarkus-catalog</artifactId>
<name>Camel Quarkus :: Catalog</name>
- <modules>
- <module>camel-quarkus-catalog</module>
- </modules>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.slf4j</groupId>
+ <artifactId>slf4j-jboss-logging</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <!-- generate and include all components in the catalog -->
+ <plugin>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-package-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <dependencies>
+ <!-- include camel-catalog on classpath -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <!-- prepare the catalog and update doc files, etc. -->
+ <goals>
+ <goal>prepare-catalog-quarkus</goal>
+ <goal>update-doc-extensions-list</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <extensionDirs>
+ <extensionDir>${camel.quarkus.project.root}/extensions-core</extensionDir>
+ <extensionDir>${camel.quarkus.project.root}/extensions</extensionDir>
+ </extensionDirs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ </build>
</project>
diff --git a/catalog/camel-quarkus-catalog/src/main/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProvider.java b/catalog/src/main/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProvider.java
similarity index 100%
rename from catalog/camel-quarkus-catalog/src/main/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProvider.java
rename to catalog/src/main/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProvider.java
diff --git a/catalog/camel-quarkus-catalog/src/main/resources/META-INF/LICENSE.txt b/catalog/src/main/resources/META-INF/LICENSE.txt
similarity index 100%
rename from catalog/camel-quarkus-catalog/src/main/resources/META-INF/LICENSE.txt
rename to catalog/src/main/resources/META-INF/LICENSE.txt
diff --git a/catalog/camel-quarkus-catalog/src/main/resources/META-INF/NOTICE.txt b/catalog/src/main/resources/META-INF/NOTICE.txt
similarity index 100%
rename from catalog/camel-quarkus-catalog/src/main/resources/META-INF/NOTICE.txt
rename to catalog/src/main/resources/META-INF/NOTICE.txt
diff --git a/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java b/catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java
similarity index 100%
rename from catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java
rename to catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java
diff --git a/tooling/package-maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java b/tooling/package-maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java
index 0a07936..ea76e65 100644
--- a/tooling/package-maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java
+++ b/tooling/package-maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java
@@ -72,7 +72,8 @@ import static org.apache.camel.tooling.util.PackageHelper.loadText;
@Mojo(name = "prepare-catalog-quarkus", threadSafe = true, requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class PrepareCatalogQuarkusMojo extends AbstractMojo {
- private static final Set<String> EXCLUDE_EXTENSIONS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("http-common", "support")));
+ private static final Set<String> EXCLUDE_EXTENSIONS = Collections
+ .unmodifiableSet(new HashSet<>(Arrays.asList("http-common", "support")));
/**
* The maven project.
@@ -119,14 +120,14 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
/**
* The directory where all quarkus extension starters are
*/
- @Parameter(defaultValue = "${project.build.directory}/../../../extensions")
- protected File extensionsDir;
+ @Parameter(property = "camel.quarkus.extensionDirs")
+ protected List<String> extensionDirs;
/**
* 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
@@ -139,7 +140,8 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
appendOthers(extensions, camelCatalog);
}
- protected void doExecute(List<CamelQuarkusExtension> extensions, Kind kind, CamelCatalog catalog) throws MojoExecutionException {
+ protected void doExecute(List<CamelQuarkusExtension> extensions, Kind kind, CamelCatalog catalog)
+ throws MojoExecutionException {
final Path outsDir = kind.getPath(this);
@@ -188,7 +190,8 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
}
}
- protected void appendOthers(List<CamelQuarkusExtension> extensions, CamelCatalog catalog) throws MojoExecutionException, MojoFailureException {
+ protected void appendOthers(List<CamelQuarkusExtension> extensions, CamelCatalog catalog)
+ throws MojoExecutionException, MojoFailureException {
// make sure to create out dir
othersOutDir.mkdirs();
final Path othersPropertiesPath = othersOutDir.toPath().resolve("../others.properties");
@@ -239,7 +242,8 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
}
}
try {
- Files.write(othersPropertiesPath, names.stream().collect(Collectors.joining("\n")).getBytes(StandardCharsets.UTF_8));
+ Files.write(othersPropertiesPath,
+ names.stream().collect(Collectors.joining("\n")).getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException("Could not write to " + othersPropertiesPath, e);
}
@@ -256,17 +260,22 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
}
private List<CamelQuarkusExtension> findExtensionModules() {
- try {
- return Files.list(extensionsDir.toPath())
- .filter(Files::isDirectory)
- .filter(path -> !EXCLUDE_EXTENSIONS.contains(path.getFileName().toString()))
- .map(path -> path.resolve("pom.xml"))
- .filter(Files::exists)
- .map(CamelQuarkusExtension::read)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new RuntimeException("Could not list " + extensionsDir, e);
- }
+ final Path basePath = project.getBasedir().toPath();
+ return extensionDirs.stream()
+ .map(relPath -> basePath.resolve(relPath))
+ .flatMap(extensionsDir -> {
+ try {
+ return Files.list(extensionsDir);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ })
+ .filter(Files::isDirectory)
+ .filter(path -> !EXCLUDE_EXTENSIONS.contains(path.getFileName().toString()))
+ .map(path -> path.resolve("pom.xml"))
+ .filter(Files::exists)
+ .map(CamelQuarkusExtension::read)
+ .collect(Collectors.toList());
}
enum Kind {
@@ -314,11 +323,12 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
public Path getPath(PrepareCatalogQuarkusMojo mojo) {
return mojo.othersOutDir.toPath();
}
- }
- ;
+ };
public abstract String getName(JsonObject json);
+
public abstract Path getPath(PrepareCatalogQuarkusMojo mojo);
+
public String getSingularName() {
return name().substring(0, name().length() - 1);
}
@@ -342,24 +352,24 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
final JsonParser jsonParser = new JsonParser();
final Map<String, List<JsonObject>> entries = new HashMap<>();
propsReader.lines()
- .map(name -> {
- final String rPath = "org/apache/camel/catalog/" + kind + "/" + name + ".json";
- try (Reader r = new InputStreamReader(PrepareCatalogQuarkusMojo.class.getClassLoader()
- .getResourceAsStream(rPath ), StandardCharsets.UTF_8)) {
- return jsonParser.parse(r).getAsJsonObject();
- } catch (IOException e) {
- throw new RuntimeException("Could not load resource " + rPath + " from class path", e);
- }
- })
- .forEach(json -> {
- String aid = json.get(kind.getSingularName()).getAsJsonObject().get("artifactId").getAsString();
- List<JsonObject> jsons = entries.get(aid);
- if (jsons == null) {
- jsons = new ArrayList<JsonObject>();
- entries.put(aid, jsons);
- }
- jsons.add(json);
- });
+ .map(name -> {
+ final String rPath = "org/apache/camel/catalog/" + kind + "/" + name + ".json";
+ try (Reader r = new InputStreamReader(PrepareCatalogQuarkusMojo.class.getClassLoader()
+ .getResourceAsStream(rPath), StandardCharsets.UTF_8)) {
+ return jsonParser.parse(r).getAsJsonObject();
+ } catch (IOException e) {
+ throw new RuntimeException("Could not load resource " + rPath + " from class path", e);
+ }
+ })
+ .forEach(json -> {
+ String aid = json.get(kind.getSingularName()).getAsJsonObject().get("artifactId").getAsString();
+ List<JsonObject> jsons = entries.get(aid);
+ if (jsons == null) {
+ jsons = new ArrayList<JsonObject>();
+ entries.put(aid, jsons);
+ }
+ jsons.add(json);
+ });
entriesByKindByArtifactId.put(kind, entries);
@@ -411,7 +421,7 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
Optional<Dependency> artifact = deps.stream()
.filter(dep ->
- "org.apache.camel".equals(dep.getGroupId()) &&
+ "org.apache.camel".equals(dep.getGroupId()) &&
("compile".equals(dep.getScope()) || dep.getScope() == null))
.findFirst();
if (artifact.isPresent()) {
@@ -433,10 +443,9 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
aid,
name,
runtimePom.getDescription(),
- props.getProperty("label")
- );
+ props.getProperty("label"));
} catch (IOException | XmlPullParserException e) {
- throw new RuntimeException("Could not read "+ parentPomXmlPath, e);
+ throw new RuntimeException("Could not read " + parentPomXmlPath, e);
}
}