You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:26:35 UTC

[sling-slingstart-maven-plugin] 05/10: SLING-4766 Provisioning Model does not support adding variables to Sling Settings - allow escaping with \${var}

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag slingstart-maven-plugin-1.2.0
in repository https://gitbox.apache.org/repos/asf/sling-slingstart-maven-plugin.git

commit 320de8f41dbfb609bc2ff7269e9f1b16c00d1218
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Jun 4 20:47:35 2015 +0000

    SLING-4766 Provisioning Model does not support adding variables to Sling Settings - allow escaping with \${var}
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1683639 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  2 +-
 .../sling/maven/slingstart/PreparePackageMojo.java | 22 ++++++++++++++++++----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2c9bca0..44ccbc2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.provisioning.model</artifactId>
-           <version>1.1.0</version>
+           <version>1.1.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
diff --git a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
index 28c14d2..6e0a5b3 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
@@ -200,7 +200,8 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
     throws MojoExecutionException{
         for(final ArtifactGroup group : runMode.getArtifactGroups()) {
             for(final org.apache.sling.provisioning.model.Artifact a : group) {
-                final Artifact artifact = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver, a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier());
+                final Artifact artifact = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver, 
+                        a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier());
                 final File artifactFile = artifact.getFile();
                 contentsMap.put(getPathForArtifact(group.getStartLevel(), artifactFile.getName(), runMode, isBoot), artifactFile);
             }
@@ -245,7 +246,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
             final RunMode launchpadRunMode = launchpadFeature.getRunMode(null);
             if ( launchpadRunMode != null ) {
                 for(final Map.Entry<String, String> entry : launchpadRunMode.getSettings()) {
-                    settings.put(entry.getKey(), entry.getValue());
+                    settings.put(entry.getKey(), deescapeVariablePlaceholders(entry.getValue()));
                 }
             }
         }
@@ -254,7 +255,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
             final RunMode bootRunMode = bootFeature.getRunMode(null);
             if ( bootRunMode != null ) {
                 for(final Map.Entry<String, String> entry : bootRunMode.getSettings()) {
-                    settings.put(entry.getKey(), entry.getValue());
+                    settings.put(entry.getKey(), deescapeVariablePlaceholders(entry.getValue()));
                 }
             }
         }
@@ -262,7 +263,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
             final RunMode packageRM = f.getRunMode(new String[] {packageRunMode});
             if ( packageRM != null ) {
                 for(final Map.Entry<String, String> entry : packageRM.getSettings()) {
-                    settings.put(entry.getKey(), entry.getValue());
+                    settings.put(entry.getKey(), deescapeVariablePlaceholders(entry.getValue()));
                 }
             }
         }
@@ -451,4 +452,17 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
                 mainName,
                 alias);
     }
+    
+    /**
+     * Replace \${var} with ${var}
+     * @param text String with escaped variables
+     * @return String with deescaped variables
+     */
+    private String deescapeVariablePlaceholders(String text) {
+        if (text == null) {
+            return null;
+        }
+        return text.replaceAll("\\\\\\$", "\\$");
+    }
+    
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.