in src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java [469:515]
private void processAttachments(final Environment env, final ProjectInfo info)
throws MavenExecutionException {
final Xpp3Dom config = info.plugin == null ? null : (Xpp3Dom)info.plugin.getConfiguration();
final Xpp3Dom[] nodes = (config == null ? null : config.getChildren("attach"));
if ( nodes != null ) {
for(final Xpp3Dom node : nodes) {
final String type = nodeValue(node, "type", null);
if ( type == null ) {
throw new MavenExecutionException("Attachment for provisioning model has no type.", (File)null);
}
final String classifier = nodeValue(node, "classifier", null);
final String featureName = nodeValue(node, "feature", null);
int startLevel = 0;
final String level = nodeValue(node, "startLevel", null);
if ( level != null ) {
startLevel = Integer.valueOf(level);
}
final Feature f;
if ( featureName != null ) {
f = info.localModel.getFeature(featureName);
} else if ( info.localModel.getFeatures().isEmpty() ) {
f = null;
} else {
f = info.localModel.getFeatures().get(0);
}
if ( f == null ) {
if ( featureName == null ) {
throw new MavenExecutionException("No feature found in provisioning model for attachment.", (File)null);
}
throw new MavenExecutionException("Feature with name '" + featureName + "' not found in provisioning model for attachment.", (File)null);
}
final RunMode runMode = f.getOrCreateRunMode(null);
final ArtifactGroup group = runMode.getOrCreateArtifactGroup(startLevel);
final org.apache.sling.provisioning.model.Artifact artifact = new org.apache.sling.provisioning.model.Artifact(
info.project.getGroupId(),
info.project.getArtifactId(),
info.project.getVersion(),
classifier,
type);
env.logger.debug("Attaching " + artifact + " to feature " + f.getName());
group.add(artifact);
}
}
}