You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/06/01 11:31:14 UTC
svn commit: r1797196 - in
/sling/whiteboard/cziegeler/feature-modelconverter: pom.xml
src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
Author: cziegeler
Date: Thu Jun 1 11:31:14 2017
New Revision: 1797196
URL: http://svn.apache.org/viewvc?rev=1797196&view=rev
Log:
Use feature support module
Modified:
sling/whiteboard/cziegeler/feature-modelconverter/pom.xml
sling/whiteboard/cziegeler/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
Modified: sling/whiteboard/cziegeler/feature-modelconverter/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-modelconverter/pom.xml?rev=1797196&r1=1797195&r2=1797196&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-modelconverter/pom.xml (original)
+++ sling/whiteboard/cziegeler/feature-modelconverter/pom.xml Thu Jun 1 11:31:14 2017
@@ -56,7 +56,7 @@
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
- <includeArtifactIds>org.apache.sling.feature,org.apache.sling.commons.johnzon,org.apache.sling.provisioning.model</includeArtifactIds>
+ <includeArtifactIds>org.apache.sling.feature,org.apache.sling.feature.support,org.apache.sling.commons.johnzon,org.apache.sling.provisioning.model</includeArtifactIds>
</configuration>
</execution>
</executions>
@@ -86,6 +86,12 @@
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.feature.support</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.provisioning.model</artifactId>
Modified: sling/whiteboard/cziegeler/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java?rev=1797196&r1=1797195&r2=1797196&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java (original)
+++ sling/whiteboard/cziegeler/feature-modelconverter/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java Thu Jun 1 11:31:14 2017
@@ -21,6 +21,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
@@ -33,6 +34,7 @@ import org.apache.sling.feature.Artifact
import org.apache.sling.feature.Extension;
import org.apache.sling.feature.ExtensionType;
import org.apache.sling.feature.json.ApplicationJSONWriter;
+import org.apache.sling.feature.support.Logger;
import org.apache.sling.provisioning.model.Artifact;
import org.apache.sling.provisioning.model.ArtifactGroup;
import org.apache.sling.provisioning.model.Configuration;
@@ -50,16 +52,16 @@ import org.apache.sling.provisioning.mod
public class Main {
public static void main(final String[] args) {
- System.out.println("Apache Sling Provisiong Model to Feature Application Converter");
+ Logger.LOG.log("Apache Sling Provisiong Model to Feature Application Converter");
System.out.println();
// first argument is either a model file or a model directory
if ( args.length == 0 ) {
- System.err.println("Required argument missing: model file or directory");
+ Logger.LOG.error("Required argument missing: model file or directory");
System.exit(1);
}
if ( args.length > 3 ) {
- System.err.println("Too many arguments. Only three (model file/dir, run modes and output file) are supported");
+ Logger.LOG.error("Too many arguments. Only three (model file/dir, run modes and output file) are supported");
System.exit(1);
}
String runModes = null;
@@ -80,9 +82,10 @@ public class Main {
}
}
if ( list.isEmpty() ) {
- System.err.println("No files found in " + f);
+ Logger.LOG.error("No files found in {0}", f);
System.exit(1);
}
+ Collections.sort(list);
files = list.toArray(new File[list.size()]);
} else {
files = new File[] {f};
@@ -151,11 +154,12 @@ public class Main {
}
private static void writeApplication(final Application app, final String out) {
+ Logger.LOG.log("Writing application...");
final File file = new File(out);
try ( final FileWriter writer = new FileWriter(file)) {
ApplicationJSONWriter.write(writer, app);
} catch ( final IOException ioe) {
- System.err.println("Unable to write application to " + out + " : " + ioe.getMessage());
+ Logger.LOG.error("Unable to write application to {0} : {1}", ioe, out, ioe.getMessage());
System.exit(1);
}
}
@@ -165,14 +169,13 @@ public class Main {
*/
private static Model createModel(final File[] files,
final String runModes) {
- System.out.println("Assembling model...");
+ Logger.LOG.log("Assembling model...");
Model model = null;
for(final File initFile : files) {
try {
model = processModel(model, initFile);
} catch ( final IOException iae) {
- System.err.println("Unable to read provisioning model " + initFile + " : "+ iae.getMessage());
- iae.printStackTrace();
+ Logger.LOG.error("Unable to read provisioning model {0} : {1}", iae, initFile, iae.getMessage());
System.exit(1);
}
}
@@ -189,9 +192,9 @@ public class Main {
}));
final Map<Traceable, String> errors = ModelUtility.validate(effectiveModel);
if ( errors != null ) {
- System.err.println("Invalid assembled provisioning model.");
+ Logger.LOG.error("Invalid assembled provisioning model.");
for(final Map.Entry<Traceable, String> entry : errors.entrySet()) {
- System.err.println("- " + entry.getKey().getLocation() + " : " + entry.getValue());
+ Logger.LOG.error("- {0} : {1}", entry.getKey().getLocation(), entry.getValue());
}
System.exit(1);
}
@@ -211,7 +214,7 @@ public class Main {
*/
private static Model processModel(Model model,
final File modelFile) throws IOException {
- System.out.println("- reading model " + modelFile);
+ Logger.LOG.log("- reading model {0}", modelFile);
final Model nextModel = readProvisioningModel(modelFile);
// resolve references to other models
@@ -232,7 +235,7 @@ public class Main {
if ( "slingstart".equals(a.getType())
|| "slingfeature".equals(a.getType())) {
- System.out.println("Ignoring referenced model: " + a);
+ Logger.LOG.warn("Ignoring referenced model: {0}", a);
removeList.add(a);
}