diff --git a/pom.xml b/pom.xml
index dd1e28b19..9fbd1b4b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,6 +46,7 @@
0.9.12
3.10
1.8
+ 1.14
2.7.0
3.15.0
2.13.1
diff --git a/tooling/camel-k-maven-plugin/pom.xml b/tooling/camel-k-maven-plugin/pom.xml
index 5029079b4..512bcf500 100644
--- a/tooling/camel-k-maven-plugin/pom.xml
+++ b/tooling/camel-k-maven-plugin/pom.xml
@@ -138,6 +138,11 @@
commons-text
${commons-text.version}
+
+ commons-codec
+ commons-codec
+ ${commons-codec.version}
+
com.vdurmont
semver4j
@@ -235,10 +240,13 @@
${quarkus.version}
+
+ generate-dependencies/pom.xml
${project.build.directory}/it
true
@@ -246,7 +254,7 @@
true
true
- generate-resources
+ prepare-package
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/pom.xml b/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/pom.xml
index 898fb50ba..e8c0ab74b 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/pom.xml
+++ b/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/pom.xml
@@ -28,6 +28,7 @@
1.0.0
+ UTF-8
${project.basedir}
main
catalog.yaml
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/pom.xml b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/pom.xml
index 9bf0b37ed..6d804cc6a 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/pom.xml
+++ b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/pom.xml
@@ -28,6 +28,7 @@
1.0.0
+ UTF-8
${project.basedir}
quarkus
catalog.yaml
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-dependencies/pom.xml b/tooling/camel-k-maven-plugin/src/it/generate-dependencies/pom.xml
new file mode 100644
index 000000000..2c2e06016
--- /dev/null
+++ b/tooling/camel-k-maven-plugin/src/it/generate-dependencies/pom.xml
@@ -0,0 +1,107 @@
+
+
+
+
+ 4.0.0
+ org.apache.camel.k
+ camel-k-catalog-generator
+ 1.0.0
+
+
+ UTF-8
+ ${project.basedir}/dependencies.yaml
+
+
+
+
+ commons-codec
+ commons-codec
+ 1.14
+
+
+
+
+
+ org.apache.camel.k
+ camel-k-maven-plugin
+ @project.version@
+
+
+ generate-dependency-list
+
+ generate-dependency-list
+
+
+
+
+
+
+
+
+
+ apache.snapshots
+ Apache Development Snapshot Repository
+ https://repository.apache.org/content/repositories/snapshots/
+
+ false
+
+
+ true
+
+
+
+ oss.snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+
+ apache.snapshots
+ Apache Development Snapshot Repository
+ https://repository.apache.org/content/repositories/snapshots/
+
+ false
+
+
+ true
+
+
+
+ oss.snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-dependencies/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-dependencies/verify.groovy
new file mode 100644
index 000000000..6beb07402
--- /dev/null
+++ b/tooling/camel-k-maven-plugin/src/it/generate-dependencies/verify.groovy
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+import org.apache.commons.codec.digest.DigestUtils
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+
+new File(basedir, "dependencies.yaml").withReader {
+ def deps = new groovy.yaml.YamlSlurper().parse(it)
+
+ for (Map dependency: deps.dependencies) {
+ dependency.checksum != null
+ dependency.location != null
+ dependency.id != null
+
+ File checksum
+
+ if ((checksum = new File("${dependency.location}.md5")).exists()) {
+ dependency.checksum == "md5:" + Files.readString(checksum.toPath(), StandardCharsets.UTF_8)
+ } else if ((checksum = new File("${dependency.location}.sha1")).exists()) {
+ dependency.checksum == "sha1:" + Files.readString(checksum.toPath(), StandardCharsets.UTF_8)
+ } else {
+ def file = new File(dependency.location)
+ def bytes = Files.readAllBytes(file.toPath())
+
+ dependency.checksum == "sha1:" + DigestUtils.sha1Hex(bytes)
+ }
+ }
+}
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/pom.xml b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/pom.xml
index 1a5f35ca7..62b079c09 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/pom.xml
+++ b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/pom.xml
@@ -28,6 +28,7 @@
1.0.0
+ UTF-8
${project.basedir}/document.json
${project.basedir}/document.xml
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/pom.xml b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/pom.xml
index b291cd794..4031f2093 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/pom.xml
+++ b/tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v3/pom.xml
@@ -28,6 +28,7 @@
1.0.0
+ UTF-8
${project.basedir}/document.yaml
${project.basedir}/document.xml
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java
index 768bd4423..4c60fe9b8 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java
@@ -17,17 +17,19 @@
package org.apache.camel.k.tooling.maven;
import java.io.IOException;
+import java.io.InputStream;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import org.apache.commons.codec.digest.DigestUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.plugin.AbstractMojo;
@@ -49,10 +51,12 @@
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class GenerateDependencyListMojo extends AbstractMojo {
+ private final String[] CHECKSUM_TYPES = { "md5", "sha1"};
+
@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject project;
- @Parameter(defaultValue = "${project.build.directory}/dependencies.yaml")
+ @Parameter(property = "dependencies.file", defaultValue = "${project.build.directory}/dependencies.yaml")
private String outputFile;
@Parameter(defaultValue = "true")
@@ -60,6 +64,7 @@ public class GenerateDependencyListMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info(">>>" + this.outputFile);
final Path output = Paths.get(this.outputFile);
try {
@@ -92,13 +97,40 @@ private boolean isCompileOrRuntime(Artifact artifact) {
}
private Map artifactToMap(Artifact artifact) {
- Map dep = new HashMap<>();
+ Map dep = new LinkedHashMap<>();
dep.put("id", artifact.getId());
- if (includeLocation && artifact.getFile() != null) {
+ if (artifact.getFile() == null) {
+ return dep;
+ }
+
+ if (includeLocation) {
dep.put("location", artifact.getFile().getAbsolutePath());
}
+ try {
+ String location = artifact.getFile().getAbsolutePath();
+ String checksum = null;
+
+ for (String checksumType : CHECKSUM_TYPES) {
+ Path checksumFile = Paths.get(location + "." + checksumType);
+ if (Files.exists(checksumFile)) {
+ checksum = checksumType + ":" + Files.readString(checksumFile, StandardCharsets.UTF_8);
+ break;
+ }
+ }
+
+ if (checksum == null) {
+ try (InputStream is = Files.newInputStream(artifact.getFile().toPath())) {
+ checksum = "sh1:" + DigestUtils.sha1Hex(is);
+ }
+ }
+
+ dep.put("checksum", checksum);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
return dep;
}
}