This is an automated email from the ASF dual-hosted git repository.

claudio4j pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/main by this push:
     new 48043b80 Fix: add classifier field to the maven artifact abstraction 
(#1161)
48043b80 is described below

commit 48043b80f2e34770b51d6c1388c1c6d9195583ca
Author: Claudio Miranda <clau...@claudius.com.br>
AuthorDate: Thu Feb 1 11:14:03 2024 -0300

    Fix: add classifier field to the maven artifact abstraction (#1161)
    
    Update jolokia to 2.0.0
---
 .../org/apache/camel/k/catalog/model/Artifact.java | 34 +++++++++++++++++++++-
 .../camel/k/catalog/model/CamelCapability.java     | 11 ++++++-
 .../camel/k/tooling/maven/GenerateCatalogMojo.java | 23 ++++++++-------
 support/camel-k-runtime-bom/pom.xml                |  7 +++--
 4 files changed, 60 insertions(+), 15 deletions(-)

diff --git 
a/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/Artifact.java
 
b/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/Artifact.java
index c27482db..8c59c761 100644
--- 
a/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/Artifact.java
+++ 
b/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/Artifact.java
@@ -21,10 +21,11 @@ import java.util.Optional;
 
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
 
-@JsonPropertyOrder({"groupId", "artifactId", "version"})
+@JsonPropertyOrder({"groupId", "artifactId", "classifier", "version"})
 public interface Artifact extends Comparable<Artifact> {
     String getGroupId();
     String getArtifactId();
+    Optional<String> getClassifier();
     Optional<String> getVersion();
 
     @Override
@@ -33,6 +34,7 @@ public interface Artifact extends Comparable<Artifact> {
             .comparing(Artifact::getGroupId)
             .thenComparing(Artifact::getArtifactId)
             .thenComparing(Artifact::getVersion, Comparator.comparing(c -> 
c.orElse("")))
+            .thenComparing(Artifact::getClassifier, Comparator.comparing(c -> 
c.orElse("")))
             .compare(this, o);
     }
 
@@ -48,10 +50,40 @@ public interface Artifact extends Comparable<Artifact> {
                 return artifactId;
             }
 
+            @Override
+            public Optional<String> getClassifier() {
+                return Optional.empty();
+            }
+
+            @Override
+            public Optional<String> getVersion() {
+                return Optional.empty();
+            }
+        };
+    }
+
+    static Artifact from(String groupId, String artifactId, String classifier) 
{
+        return new Artifact() {
+            @Override
+            public String getGroupId() {
+                return groupId;
+            }
+
+            @Override
+            public String getArtifactId() {
+                return artifactId;
+            }
+
+            @Override
+            public Optional<String> getClassifier() {
+                return Optional.of(classifier);
+            }
+
             @Override
             public Optional<String> getVersion() {
                 return Optional.empty();
             }
         };
     }
+
 }
diff --git 
a/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelCapability.java
 
b/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelCapability.java
index 0b6c6400..5312dbd6 100644
--- 
a/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelCapability.java
+++ 
b/support/camel-k-catalog-model/src/main/java/org/apache/camel/k/catalog/model/CamelCapability.java
@@ -17,6 +17,7 @@
 package org.apache.camel.k.catalog.model;
 
 import java.util.Collections;
+import java.util.Optional;
 import java.util.SortedSet;
 
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@@ -26,7 +27,7 @@ import org.immutables.value.Value;
 @Value.Immutable
 @Value.Style(depluralize = true)
 @JsonDeserialize(builder = CamelCapability.Builder.class)
-@JsonPropertyOrder({"groupId", "artifactId", "version"})
+@JsonPropertyOrder({"groupId", "artifactId", "classifier","version"})
 public interface CamelCapability {
     @Value.Auxiliary
     @Value.Default
@@ -43,5 +44,13 @@ public interface CamelCapability {
         public Builder addDependency(String groupId, String artifactId) {
             return super.addDependencies(Artifact.from(groupId, artifactId));
         }
+
+        public Builder addDependency(String groupId, String artifactId, 
Optional<String> classifier) {
+            if (classifier.isEmpty()) {
+                return super.addDependencies(Artifact.from(groupId, 
artifactId));
+            } else {
+                return super.addDependencies(Artifact.from(groupId, 
artifactId, classifier.get()));
+            }
+        }
     }
 }
diff --git 
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
 
b/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index c74df629..aee15b04 100644
--- 
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++ 
b/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -524,23 +524,26 @@ public class GenerateCatalogMojo extends AbstractMojo {
         artifacts.clear();
         artifacts.add(Artifact.from("org.apache.camel.quarkus", 
"camel-quarkus-management"));
         artifacts.add(Artifact.from("org.apache.camel.quarkus", 
"camel-quarkus-jaxb"));
-        artifacts.add(Artifact.from("org.jolokia", "jolokia-jvm"));
-        addCapabilityAndDependecies(runtimeSpec, catalogSpec, "jolokia", 
artifacts, false);
+        artifacts.add(Artifact.from("org.jolokia", "jolokia-agent-jvm", 
"javaagent"));
+        addCapabilityAndDependecies(runtimeSpec, catalogSpec, "jolokia", 
artifacts, true);
     }
 
     private void addCapabilityAndDependecies(RuntimeSpec.Builder runtimeSpec, 
CamelCatalogSpec.Builder catalogSpec, String name,
-        List<Artifact> artifacts, boolean addDependency) {
+            List<Artifact> artifacts, boolean addDependency) {
         if (capabilitiesExclusionList != null && 
!capabilitiesExclusionList.contains(name)) {
             CamelCapability.Builder capBuilder = new CamelCapability.Builder();
-            artifacts.forEach(artifact -> 
capBuilder.addDependency(artifact.getGroupId(), artifact.getArtifactId()));
+            artifacts.forEach(artifact -> {
+                capBuilder.addDependency(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getClassifier());
+                if (addDependency) {
+                    catalogSpec.putArtifact(new CamelArtifact.Builder()
+                        .groupId(artifact.getGroupId())
+                        .artifactId(artifact.getArtifactId())
+                        .classifier(artifact.getClassifier())
+                        .build());
+                }
+            });
             CamelCapability dependency = capBuilder.build();
             runtimeSpec.putCapability(name, dependency);
-            if (addDependency && !artifacts.isEmpty()) {
-                catalogSpec.putArtifact(new CamelArtifact.Builder()
-                    .groupId(artifacts.get(0).getGroupId())
-                    .artifactId(artifacts.get(0).getArtifactId())
-                    .build());
-            }
         }
 
     }
diff --git a/support/camel-k-runtime-bom/pom.xml 
b/support/camel-k-runtime-bom/pom.xml
index 3cff17a4..de9edf60 100644
--- a/support/camel-k-runtime-bom/pom.xml
+++ b/support/camel-k-runtime-bom/pom.xml
@@ -35,7 +35,7 @@
     <properties>
         <!-- reproduceable builds: 
https://maven.apache.org/guides/mini/guide-reproducible-builds.html -->
         
<project.build.outputTimestamp>1702292687</project.build.outputTimestamp>
-        <jolokia-version>1.7.2</jolokia-version>
+        <jolokia-version>2.0.1</jolokia-version>
         <maven-enforcer-plugin-version>3.4.1</maven-enforcer-plugin-version>
         <maven-version>3.8.6</maven-version>
         <quarkus-platform-group>io.quarkus.platform</quarkus-platform-group>
@@ -173,12 +173,13 @@
             </dependency>
             <dependency>
                 <groupId>org.jolokia</groupId>
-                <artifactId>jolokia-jvm</artifactId>
+                <artifactId>jolokia-agent-jvm</artifactId>
                 <version>${jolokia-version}</version>
+                <classifier>javaagent</classifier>
                 <exclusions>
                     <exclusion>
                         <groupId>org.jolokia</groupId>
-                        <artifactId>jolokia-core</artifactId>
+                        <artifactId>jolokia-server-core</artifactId>
                     </exclusion>
                     <exclusion>
                         <groupId>com.googlecode.json-simple</groupId>

Reply via email to