This is an automated email from the ASF dual-hosted git repository. simonetripodi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git
commit 6053648d47d6b9c23329601a8ea5dae110436315 Author: stripodi <[email protected]> AuthorDate: Fri Apr 12 00:04:12 2019 +0200 specify the whole artifact id, rather than overriding pieces --- .../ContentPackage2FeatureModelConverter.java | 58 ++++++++++++---------- ...ntentPackage2FeatureModelConverterLauncher.java | 4 +- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java b/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java index 966728c..8c051e8 100644 --- a/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java +++ b/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java @@ -92,7 +92,7 @@ public class ContentPackage2FeatureModelConverter { private VaultPackageAssembler mainPackageAssembler = null; - private String groupId; + private String id; public ContentPackage2FeatureModelConverter setStrictValidation(boolean strictValidation) { this.strictValidation = strictValidation; @@ -144,8 +144,8 @@ public class ContentPackage2FeatureModelConverter { filter.addFilteringPattern(filteringPattern); } - public ContentPackage2FeatureModelConverter setGroupId(String groupId) { - this.groupId = groupId; + public ContentPackage2FeatureModelConverter setId(String id) { + this.id = id; return this; } @@ -210,34 +210,38 @@ public class ContentPackage2FeatureModelConverter { logger.info("content-package '{}' successfully read!", contentPackage); mainPackageAssembler = VaultPackageAssembler.create(vaultPackage); - PackageProperties packageProperties = vaultPackage.getProperties(); - String group; - if (groupId != null && !groupId.isEmpty()) { - group = groupId; + + ArtifactId artifactId; + if (id != null && !id.isEmpty()) { + artifactId = ArtifactId.fromMvnId(id); } else { - group = requireNonNull(packageProperties.getProperty(PackageProperties.NAME_GROUP), - "'packageGroupId' parameter not specified and " - + PackageProperties.NAME_GROUP - + " property not found in content-package " - + contentPackage - + ", please check META-INF/vault/properties.xml"); - } - String name = requireNonNull(packageProperties.getProperty(PackageProperties.NAME_NAME), - PackageProperties.NAME_NAME - + " property not found in content-package " - + contentPackage - + ", please check META-INF/vault/properties.xml"); - String version = packageProperties.getProperty(PackageProperties.NAME_VERSION); - if (version == null || version.isEmpty()) { - version = DEFEAULT_VERSION; + String group = requireNonNull(packageProperties.getProperty(PackageProperties.NAME_GROUP), + PackageProperties.NAME_GROUP + + " property not found in content-package " + + contentPackage + + ", please check META-INF/vault/properties.xml") + .replace('/', '.'); + + String name = requireNonNull(packageProperties.getProperty(PackageProperties.NAME_NAME), + PackageProperties.NAME_NAME + + " property not found in content-package " + + contentPackage + + ", please check META-INF/vault/properties.xml"); + + String version = packageProperties.getProperty(PackageProperties.NAME_VERSION); + if (version == null || version.isEmpty()) { + version = DEFEAULT_VERSION; + } + + artifactId = new ArtifactId(group, + name, + version, + FEATURE_CLASSIFIER, + SLING_OSGI_FEATURE_TILE_TYPE); } - targetFeature = new Feature(new ArtifactId(group.replace('/', '.'), - name, - version, - FEATURE_CLASSIFIER, - SLING_OSGI_FEATURE_TILE_TYPE)); + targetFeature = new Feature(artifactId); targetFeature.setDescription(packageProperties.getDescription()); diff --git a/src/main/java/org/apache/sling/feature/cpconverter/cli/ContentPackage2FeatureModelConverterLauncher.java b/src/main/java/org/apache/sling/feature/cpconverter/cli/ContentPackage2FeatureModelConverterLauncher.java index 2943f82..e780d10 100644 --- a/src/main/java/org/apache/sling/feature/cpconverter/cli/ContentPackage2FeatureModelConverterLauncher.java +++ b/src/main/java/org/apache/sling/feature/cpconverter/cli/ContentPackage2FeatureModelConverterLauncher.java @@ -67,7 +67,7 @@ public final class ContentPackage2FeatureModelConverterLauncher implements Runna @Option(names = { "-o", "--features-output-directory" }, description = "The output directory where the Feature File will be generated.", required = true) private File featureModelsOutputDirectory; - @Option(names = { "-g", "--groupId" }, description = "The output directory where the Feature File will be generated.", required = false) + @Option(names = { "-i", "--artifact-id" }, description = "The optional Artifact Id the Feature File will have, once generated; it will be derived, if not specified.", required = false) private String groupId; @Override @@ -104,7 +104,7 @@ public final class ContentPackage2FeatureModelConverterLauncher implements Runna .setBundlesStartOrder(bundlesStartOrder) .setArtifactsOutputDirectory(artifactsOutputDirectory) .setFeatureModelsOutputDirectory(featureModelsOutputDirectory) - .setGroupId(groupId); + .setId(groupId); if (filteringPatterns != null && filteringPatterns.length > 0) { for (String filteringPattern : filteringPatterns) {
