in src/main/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojo.java [144:221]
public void execute() throws MojoExecutionException, MojoFailureException {
checkPreconditions();
List<String> arguments = new ArrayList<>();
getLog().info("Feature Selection: " + selection);
if (featureArchiveFiles != null && !featureArchiveFiles.isEmpty()) {
for (File file : featureArchiveFiles) {
handleFile(arguments, file, "-f");
}
}
ArtifactRepository artifactRepository =
this.mavenSession.getProjectBuildingRequest().getLocalRepository();
String localPath = artifactRepository.getBasedir();
if (featureArchiveClassifiers != null && !featureArchiveClassifiers.isEmpty()) {
for (String featureArchiveClassifier : featureArchiveClassifiers) {
ArtifactId id = new ArtifactId(
this.project.getGroupId(),
this.project.getArtifactId(),
this.project.getVersion(),
featureArchiveClassifier,
"far");
String artifactPath = id.toMvnPath();
getLog().info("Artifact Maven Path: " + artifactPath);
File file = new File(localPath, artifactPath);
handleFile(arguments, file, "-f");
}
}
if (featureArchiveIds != null && !featureArchiveIds.isEmpty()) {
for (String featureArchive : featureArchiveIds) {
ArtifactId id = ArtifactId.parse(featureArchive);
if (id != null) {
String artifactPath = id.toMvnPath();
getLog().info("Artifact Maven Path: " + artifactPath);
File file = new File(localPath, artifactPath);
handleFile(arguments, file, "-f");
}
}
}
if (selection != null && !selection.getSelections().isEmpty()) {
final Collection<Feature> features = getSelectedFeatures(selection).values();
getLog().info("Features from Selection: " + features);
for (Feature feature : features) {
// Loop over all features found, create a temporary file, write the features there and add them to the
// launcher's file list
File folder;
try {
folder = Files.createTempDirectory("features").toFile();
} catch (IOException e1) {
throw new MojoExecutionException("Failed to create temp directory", e1);
}
ArtifactId id = feature.getId();
File featureFile = new File(folder, id.toMvnId().replaceAll(":", "-") + ".json");
// TODO: Do we need to support Prototypes etc?
try (final Writer writer = new FileWriter(featureFile)) {
FeatureJSONWriter.write(writer, feature);
} catch (final IOException e) {
throw new MojoExecutionException("Unable to write feature file :" + id.toMvnId(), e);
}
getLog().info("Feature File Location: " + featureFile);
handleFile(arguments, featureFile, "-f");
}
}
handleStringList(arguments, artifactClashOverrides, "-C");
handleString(arguments, repositoryUrl, "-u");
handleStringList(arguments, frameworkProperties, "-D");
handleStringList(arguments, variableValues, "-V");
if (verbose) {
arguments.add("-v");
}
handleFile(arguments, cacheDirectory, "-c");
handleFile(arguments, homeDirectory, "-p");
handleStringList(arguments, extensionConfigurations, "-ec");
handleString(arguments, frameworkVersion, "-fw");
handleStringList(arguments, frameworkArtifacts, "-fa");
String[] args = arguments.toArray(new String[] {});
getLog().info("Launcher Arguments: '" + arguments + "'");
launch(args);
}