Skip to content

Commit 72f7f7f

Browse files
authored
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.
1 parent 7b5bbd9 commit 72f7f7f

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
346346
filter(inputFile, outputFile);
347347
getLog().info("Generation not enabled");
348348
getLog().info("Attaching artifact");
349-
//projectHelper.attachArtifact(project, attachmentArtifactType, attachmentArtifactClassifier, outputFile);
350-
Artifact artifact = factory.createArtifactWithClassifier(project.getGroupId(), project.getArtifactId(), project.getVersion(), attachmentArtifactType, attachmentArtifactClassifier);
351-
artifact.setFile(outputFile);
352-
project.setArtifact(artifact);
349+
if (project.getPackaging().equals("feature")) {
350+
Artifact artifact = factory.createArtifactWithClassifier(project.getGroupId(), project.getArtifactId(), project.getVersion(), attachmentArtifactType, attachmentArtifactClassifier);
351+
artifact.setFile(outputFile);
352+
project.setArtifact(artifact);
353+
} else {
354+
projectHelper.attachArtifact(project, attachmentArtifactType, attachmentArtifactClassifier, outputFile);
355+
}
353356
return;
354357
}
355358
}
@@ -364,9 +367,17 @@ public void execute() throws MojoExecutionException, MojoFailureException {
364367
try (PrintStream out = new PrintStream(new FileOutputStream(outputFile))) {
365368
writeFeatures(out);
366369
}
367-
getLog().info("Attaching features XML");
368-
// now lets attach it
369-
projectHelper.attachArtifact(project, attachmentArtifactType, attachmentArtifactClassifier, outputFile);
370+
if (project.getPackaging().equals("feature") && enableGeneration) {
371+
getLog().info("Set artifact");
372+
Artifact artifact = factory.createArtifactWithClassifier(project.getGroupId(), project.getArtifactId(), project.getVersion(), attachmentArtifactType
373+
, FEATURE_CLASSIFIER);
374+
artifact.setFile(outputFile);
375+
project.setArtifact(artifact);
376+
} else {
377+
getLog().info("Attaching features XML");
378+
// now lets attach it
379+
projectHelper.attachArtifact(project, attachmentArtifactType, attachmentArtifactClassifier, outputFile);
380+
}
370381
} else {
371382
throw new MojoExecutionException("Could not create directory for features file: " + dir);
372383
}

0 commit comments

Comments
 (0)