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

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new 72f7f7f9d3 Set features and kar artifact to the corresponding mojo 
(#2114)
72f7f7f9d3 is described below

commit 72f7f7f9d338107be9322336bf458613032fb393
Author: JB Onofré <[email protected]>
AuthorDate: Fri Nov 14 14:05:43 2025 +0100

    Set features and kar artifact to the corresponding mojo (#2114)
    
    * Deal with Kar packaging and cleanly attach artifact forcing pom packaging.
    * Also deal with packaging in the case generation is not enabled.
---
 .../tooling/features/GenerateDescriptorMojo.java   | 25 ++++++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
index 553ce91826..6357552969 100644
--- 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
+++ 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
@@ -346,10 +346,13 @@ public class GenerateDescriptorMojo extends MojoSupport {
                     filter(inputFile, outputFile);
                     getLog().info("Generation not enabled");
                     getLog().info("Attaching artifact");
-                    //projectHelper.attachArtifact(project, 
attachmentArtifactType, attachmentArtifactClassifier, outputFile);
-                    Artifact artifact = 
factory.createArtifactWithClassifier(project.getGroupId(), 
project.getArtifactId(), project.getVersion(), attachmentArtifactType, 
attachmentArtifactClassifier);
-                    artifact.setFile(outputFile);
-                    project.setArtifact(artifact);
+                    if (project.getPackaging().equals("feature")) {
+                        Artifact artifact = 
factory.createArtifactWithClassifier(project.getGroupId(), 
project.getArtifactId(), project.getVersion(), attachmentArtifactType, 
attachmentArtifactClassifier);
+                        artifact.setFile(outputFile);
+                        project.setArtifact(artifact);
+                    } else {
+                        projectHelper.attachArtifact(project, 
attachmentArtifactType, attachmentArtifactClassifier, outputFile);
+                    }
                     return;
                 }
             }
@@ -364,9 +367,17 @@ public class GenerateDescriptorMojo extends MojoSupport {
                 try (PrintStream out = new PrintStream(new 
FileOutputStream(outputFile))) {
                     writeFeatures(out);
                 }
-                getLog().info("Attaching features XML");
-                // now lets attach it
-                projectHelper.attachArtifact(project, attachmentArtifactType, 
attachmentArtifactClassifier, outputFile);
+                if (project.getPackaging().equals("feature") && 
enableGeneration) {
+                    getLog().info("Set artifact");
+                    Artifact artifact = 
factory.createArtifactWithClassifier(project.getGroupId(), 
project.getArtifactId(), project.getVersion(), attachmentArtifactType
+                    , FEATURE_CLASSIFIER);
+                    artifact.setFile(outputFile);
+                    project.setArtifact(artifact);
+                } else {
+                    getLog().info("Attaching features XML");
+                    // now lets attach it
+                    projectHelper.attachArtifact(project, 
attachmentArtifactType, attachmentArtifactClassifier, outputFile);
+                }
             } else {
                 throw new MojoExecutionException("Could not create directory 
for features file: " + dir);
             }

Reply via email to