sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-provisioning-model] 04/06: SLING-6389 : Avoid empty blank line at end of provisioning model
Date Tue, 07 Nov 2017 09:59:06 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 39d76f8d6242095b30c5d6f3d2ea9a8a8c03a461
Author: Carsten Ziegeler <cziegeler@apache.org>
AuthorDate: Mon Dec 12 13:18:22 2016 +0000

    SLING-6389 : Avoid empty blank line at end of provisioning model
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1773788
13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/provisioning/model/io/ModelWriter.java   | 25 ++++++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java b/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java
index d503628..ab0fa8b 100644
--- a/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java
+++ b/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java
@@ -84,8 +84,15 @@ public class ModelWriter {
     throws IOException {
         final PrintWriter pw = new PrintWriter(writer);
 
+        boolean firstFeature = true;
+
         // features
         for(final Feature feature : model.getFeatures()) {
+            if ( firstFeature ) {
+                firstFeature = false;
+            } else {
+                pw.println();
+            }
             writeComment(pw, feature);
             pw.print("[feature name=");
             pw.print(feature.getName());
@@ -98,10 +105,10 @@ public class ModelWriter {
                 pw.print(feature.getVersion());
             }
             pw.println("]");
-            pw.println();
 
             // variables
             if ( !feature.getVariables().isEmpty() ) {
+                pw.println();
                 writeComment(pw, feature.getVariables());
                 pw.println("[variables]");
                 for(final Map.Entry<String, String> entry : feature.getVariables())
{
@@ -110,13 +117,13 @@ public class ModelWriter {
                     pw.print("=");
                     pw.println(entry.getValue());
                 }
-                pw.println();
             }
 
             // run modes
             for(final RunMode runMode : feature.getRunModes()) {
                 // settings
                 if ( !runMode.getSettings().isEmpty() ) {
+                    pw.println();
                     writeComment(pw, runMode.getSettings());
                     pw.print("[settings");
                     writeRunMode(pw, runMode);
@@ -128,7 +135,6 @@ public class ModelWriter {
                         pw.print("=");
                         pw.println(entry.getValue());
                     }
-                    pw.println();
                 }
 
                 // artifact groups
@@ -137,6 +143,7 @@ public class ModelWriter {
                     if ( group.isEmpty() ) {
                         continue;
                     }
+                    pw.println();
                     writeComment(pw, group);
                     pw.print("[artifacts");
                     if ( group.getStartLevel() > 0 ) {
@@ -145,7 +152,6 @@ public class ModelWriter {
                     }
                     writeRunMode(pw, runMode);
                     pw.println("]");
-                    pw.println();
 
                     // artifacts
                     for(final Artifact ad : group) {
@@ -169,16 +175,22 @@ public class ModelWriter {
                         }
                         pw.println();
                     }
-                    pw.println();
                 }
 
                 // configurations
                 if ( !runMode.getConfigurations().isEmpty() ) {
+                    pw.println();
                     writeComment(pw, runMode.getConfigurations());
                     pw.print("[configurations");
                     writeRunMode(pw, runMode);
                     pw.println("]");
+                    boolean firstConfig = true;
                     for(final Configuration config : runMode.getConfigurations()) {
+                        if ( firstConfig ) {
+                            firstConfig = false;
+                        } else{
+                            pw.println();
+                        }
                         writeComment(pw, config);
                         final String raw = (String)config.getProperties().get(ModelConstants.CFG_UNPROCESSED);
                         String format = (String)config.getProperties().get(ModelConstants.CFG_UNPROCESSED_FORMAT);
@@ -238,13 +250,13 @@ public class ModelWriter {
                             pw.print("    ");
                             pw.println(line.trim());
                         }
-                        pw.println();
                     }
                 }
             }
 
             // additional sections
             for(final Section section : feature.getAdditionalSections()) {
+                pw.println();
                 pw.print("  [:");
                 pw.print(section.getName());
                 for(final Map.Entry<String, String> entry : section.getAttributes().entrySet())
{
@@ -257,7 +269,6 @@ public class ModelWriter {
                 if ( section.getContents() != null ) {
                     pw.println(section.getContents());
                 }
-                pw.println();
             }
         }
     }

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

Mime
View raw message