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 553ce91826a..63575529691 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 void execute() throws MojoExecutionException, MojoFailureException { 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 void execute() throws MojoExecutionException, MojoFailureException { 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); }