in src/main/java/org/apache/sling/cpconverter/maven/mojos/ConvertCPMojo.java [206:305]
public void execute() throws MojoExecutionException, MojoFailureException {
// Un-encode a given Artifact Override Id
if(artifactIdOverride != null) {
String old = artifactIdOverride;
artifactIdOverride = artifactIdOverride.replaceAll("\\$\\{\\{", "\\$\\{");
artifactIdOverride = artifactIdOverride.replaceAll("}}", "}");
getLog().info("Replaced Old Artifact Id Override: '" + old + "', with new one: '" + artifactIdOverride + "'");
}
// Parse the System Properties if provided
Map<String,String> properties = new HashMap<>();
if(systemProperties != null) {
for(String systemProperty: systemProperties) {
if(systemProperty != null) {
int index = systemProperty.indexOf("=");
if(index > 0 && index < systemProperty.length() - 1) {
String key = systemProperty.substring(0, index);
String value = systemProperty.substring(index + 1);
properties.put(key, value);
}
}
}
}
try {
DefaultFeaturesManager featuresManager = new DefaultFeaturesManager(
mergeConfigurations,
bundleStartOrder,
fmOutput,
artifactIdOverride,
fmPrefix,
properties
);
if (!apiRegions.isEmpty())
featuresManager.setAPIRegions(apiRegions);
if (exportToApiRegion != null)
featuresManager.setExportToAPIRegion(exportToApiRegion);
ContentPackage2FeatureModelConverter converter = new ContentPackage2FeatureModelConverter(strictValidation)
.setFeaturesManager(
featuresManager
)
.setBundlesDeployer(
new DefaultArtifactsDeployer(
convertedCPOutput
)
)
.setEntryHandlersManager(
new DefaultEntryHandlersManager()
)
.setAclManager(
new DefaultAclManager()
)
.setEmitter(DefaultPackagesEventsEmitter.open(fmOutput))
.setResourceFilter(getResourceFilter());
if(contentPackages == null || contentPackages.isEmpty()) {
getLog().info("Project Artifact File: " + project.getArtifact());
String targetPath = project.getModel().getBuild().getDirectory() + "/"
+ project.getModel().getBuild().getFinalName()
+ "." + ZIP_TYPE;
File targetFile = new File(targetPath);
if (targetFile.exists() && targetFile.isFile() && targetFile.canRead()) {
converter.convert(project.getArtifact().getFile());
} else {
getLog().error("Artifact is not found: " + targetPath);
}
} else {
for(ContentPackage contentPackage: contentPackages) {
contentPackage.setExcludeTransitive(true);
contentPackage.setModuleIsContentPackage(isContentPackage);
getLog().info("Content Package Artifact File: " + contentPackage.toString() + ", is module CP: " + isContentPackage);
final Collection<Artifact> artifacts =
contentPackage.getMatchingArtifacts(project, repoSystem, repoSession, remoteRepos);
if (artifacts.isEmpty()) {
getLog().warn("No matching artifacts for " + contentPackage);
continue;
}
getLog().info("Target Convert CP of --- " + contentPackage + " ---");
for (final Artifact artifact : artifacts) {
final File source = artifact.getFile();
getLog().info("Artifact: '" + artifact + "', source file: '" + source + "'");
if (source != null && source.exists() && source.isFile() && source.canRead()) {
converter.convert(source);
Artifact convertedPackage = new DefaultArtifact(
artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
"compile", ZIP_TYPE, PACKAGE_CLASSIFIER, artifactHandlerManager.getArtifactHandler(ZIP_TYPE)
);
// installConvertedCP(convertedPackage);
} else {
getLog().error("Artifact is not found: " + artifact);
}
}
}
}
installGeneratedArtifacts();
} catch (Throwable t) {
throw new MojoExecutionException("Content Package Converter Exception", t);
}
}