in src/main/java/org/apache/sling/feature/maven/mojos/IncludeArtifactMojo.java [137:199]
public void execute() throws MojoExecutionException, MojoFailureException {
checkPreconditions();
final Map<String, Feature> featuresMap = ProjectHelper.getFeatures(this.project);
Feature found = null;
String key = null;
for (final Map.Entry<String, Feature> entry : featuresMap.entrySet()) {
if (includeArtifactClassifier != null
&& includeArtifactClassifier.equals(entry.getValue().getId().getClassifier())) {
key = entry.getKey();
found = entry.getValue();
break;
}
}
File file = null;
if (found == null) {
found = new Feature(new ArtifactId(
this.project.getGroupId(),
this.project.getArtifactId(),
this.project.getVersion(),
includeArtifactClassifier,
FeatureConstants.PACKAGING_FEATURE));
file = new File(
this.getTmpDir(),
"feature" + (includeArtifactClassifier == null ? "" : "-" + includeArtifactClassifier) + ".json");
key = file.getAbsolutePath();
ProjectHelper.getFeatures(this.project).put(key, found);
ProjectHelper.getAssembledFeatures(this.project).put(key, found);
}
final Artifact art = new Artifact(new ArtifactId(
this.project.getGroupId(),
this.project.getArtifactId(),
this.project.getVersion(),
includeClassifier,
includeType != null ? includeType : this.project.getArtifact().getType()));
if (jarStartOrder > 0) {
art.setStartOrder(jarStartOrder);
}
if (metadata != null && metadata.size() > 0) {
art.getMetadata().putAll(metadata);
}
includeArtifact(found, includeArtifactExtension, art);
includeArtifact(
ProjectHelper.getAssembledFeatures(this.project).get(key),
includeArtifactExtension,
art.copy(art.getId()));
addDependencies(found);
if (file != null) {
try (final Writer writer = new FileWriter(file)) {
FeatureJSONWriter.write(writer, found);
} catch (final IOException ioe) {
throw new MojoExecutionException("Unable to write feature", ioe);
}
}
}