You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by an...@apache.org on 2019/08/13 22:50:28 UTC
[sling-org-apache-sling-feature-cpconverter] branch
issues/SLING-8626 created (now 620b42f)
This is an automated email from the ASF dual-hosted git repository.
andysch pushed a change to branch issues/SLING-8626
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git.
at 620b42f SLING-8626 - Added Maven Model Version to generated POM, replace any spaces in Group and Artifact IIds
This branch includes the following new commits:
new 620b42f SLING-8626 - Added Maven Model Version to generated POM, replace any spaces in Group and Artifact IIds
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[sling-org-apache-sling-feature-cpconverter] 01/01: SLING-8626 -
Added Maven Model Version to generated POM,
replace any spaces in Group and Artifact IIds
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andysch pushed a commit to branch issues/SLING-8626
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git
commit 620b42f193cfa9ef0672f20dba51e08631258536
Author: Andreas Schaefer <sc...@iMac.local>
AuthorDate: Tue Aug 13 15:50:11 2019 -0700
SLING-8626 - Added Maven Model Version to generated POM, replace any spaces in Group and Artifact IIds
---
.../ContentPackage2FeatureModelConverter.java | 21 ++++++++++++---------
.../artifacts/MavenPomSupplierWriter.java | 2 ++
.../cpconverter/handlers/BundleEntryHandler.java | 4 ++++
3 files changed, 18 insertions(+), 9 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 f9194e1..43a372a 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
@@ -143,7 +143,6 @@ public class ContentPackage2FeatureModelConverter extends BaseVaultPackageScanne
return this;
}
-
public void convert(File...contentPackages) throws Exception {
requireNonNull(contentPackages , "Null content-package(s) can not be converted.");
secondPass(firstPass(contentPackages));
@@ -325,16 +324,20 @@ public class ContentPackage2FeatureModelConverter extends BaseVaultPackageScanne
private static ArtifactId toArtifactId(VaultPackage vaultPackage) {
PackageId packageId = vaultPackage.getId();
String groupId = requireNonNull(packageId.getGroup(),
- PackageProperties.NAME_GROUP
- + " property not found in content-package "
- + vaultPackage
- + ", please check META-INF/vault/properties.xml").replace('/', '.');
+ PackageProperties.NAME_GROUP
+ + " property not found in content-package "
+ + vaultPackage
+ + ", please check META-INF/vault/properties.xml").replace('/', '.');
+ // Replace any space with an underscore to adhere to Maven Group Id specification
+ groupId = groupId.replaceAll(" ", "_");
String artifactid = requireNonNull(packageId.getName(),
- PackageProperties.NAME_NAME
- + " property not found in content-package "
- + vaultPackage
- + ", please check META-INF/vault/properties.xml");
+ PackageProperties.NAME_NAME
+ + " property not found in content-package "
+ + vaultPackage
+ + ", please check META-INF/vault/properties.xml");
+ // Replace any space with an underscore to adhere to Maven Artifact Id specification
+ artifactid = artifactid.replaceAll(" ", "_");
String version = packageId.getVersionString();
if (version == null || version.isEmpty()) {
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/artifacts/MavenPomSupplierWriter.java b/src/main/java/org/apache/sling/feature/cpconverter/artifacts/MavenPomSupplierWriter.java
index 1d09166..f1f03f4 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/artifacts/MavenPomSupplierWriter.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/artifacts/MavenPomSupplierWriter.java
@@ -34,6 +34,8 @@ public final class MavenPomSupplierWriter implements ArtifactWriter {
@Override
public void write(OutputStream outputStream) throws IOException {
Model model = new Model();
+ // Maven complains if Model Version is not set
+ model.setModelVersion("4.0.0");
model.setGroupId(id.getGroupId());
model.setArtifactId(id.getArtifactId());
model.setVersion(id.getVersion());
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
index c5eee53..ee933b0 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
@@ -81,7 +81,11 @@ public final class BundleEntryHandler extends AbstractRegexEntryHandler {
classifier = properties.getProperty(NAME_CLASSIFIER);
} else { // maybe the included jar is just an OSGi bundle but not a valid Maven artifact
groupId = getCheckedProperty(manifest, BUNDLE_SYMBOLIC_NAME);
+ // Make sure there are not spaces in the name to adhere to the Maven Group Id specification
+ groupId = groupId.replaceAll(" ", "_");
artifactId = getCheckedProperty(manifest, BUNDLE_NAME);
+ // Make sure there are not spaces in the name to adhere to the Maven Artifact Id specification
+ artifactId = artifactId.replaceAll(" ", "_");
version = getCheckedProperty(manifest, BUNDLE_VERSION);
}
}