polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [2/4] zest-java git commit: ZEST-143 : Fixing up Create Project command line tool.
Date Thu, 21 Apr 2016 11:20:12 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/etc/templates/singleton/files/gradlew_
----------------------------------------------------------------------
diff --git a/tools/shell/src/etc/templates/singleton/files/gradlew_ b/tools/shell/src/etc/templates/singleton/files/gradlew_
deleted file mode 100755
index 91a7e26..0000000
--- a/tools/shell/src/etc/templates/singleton/files/gradlew_
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-##  Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
-    echo "$*"
-}
-
-die ( ) {
-    echo
-    echo "$*"
-    echo
-    exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
-  CYGWIN* )
-    cygwin=true
-    ;;
-  Darwin* )
-    darwin=true
-    ;;
-  MINGW* )
-    msys=true
-    ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
-        # IBM's JDK on AIX uses strange locations for the executables
-        JAVACMD="$JAVA_HOME/jre/sh/java"
-    else
-        JAVACMD="$JAVA_HOME/bin/java"
-    fi
-    if [ ! -x "$JAVACMD" ] ; then
-        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-    fi
-else
-    JAVACMD="java"
-    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
-    MAX_FD_LIMIT=`ulimit -H -n`
-    if [ $? -eq 0 ] ; then
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
-            MAX_FD="$MAX_FD_LIMIT"
-        fi
-        ulimit -n $MAX_FD
-        if [ $? -ne 0 ] ; then
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
-        fi
-    else
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
-    fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
-    # We build the pattern for arguments to be converted via cygpath
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
-    SEP=""
-    for dir in $ROOTDIRSRAW ; do
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
-        SEP="|"
-    done
-    OURCYGPATTERN="(^($ROOTDIRS))"
-    # Add a user-defined pattern to the cygpath arguments
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
-    fi
-    # Now convert the arguments - kludge to limit ourselves to /bin/sh
-    i=0
-    for arg in "$@" ; do
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
-
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
-        else
-            eval `echo args$i`="\"$arg\""
-        fi
-        i=$((i+1))
-    done
-    case $i in
-        (0) set -- ;;
-        (1) set -- "$args0" ;;
-        (2) set -- "$args0" "$args1" ;;
-        (3) set -- "$args0" "$args1" "$args2" ;;
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
-    esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
-    JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/etc/templates/singleton/files/src/main/java/__package__/package.html_
----------------------------------------------------------------------
diff --git a/tools/shell/src/etc/templates/singleton/files/src/main/java/__package__/package.html_ b/tools/shell/src/etc/templates/singleton/files/src/main/java/__package__/package.html_
deleted file mode 100644
index e071c79..0000000
--- a/tools/shell/src/etc/templates/singleton/files/src/main/java/__package__/package.html_
+++ /dev/null
@@ -1 +0,0 @@
-<html><body>Package for the Java source files</body></html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/etc/templates/singleton/files/src/test/java/__package__/package.html_
----------------------------------------------------------------------
diff --git a/tools/shell/src/etc/templates/singleton/files/src/test/java/__package__/package.html_ b/tools/shell/src/etc/templates/singleton/files/src/test/java/__package__/package.html_
deleted file mode 100644
index eaefd36..0000000
--- a/tools/shell/src/etc/templates/singleton/files/src/test/java/__package__/package.html_
+++ /dev/null
@@ -1 +0,0 @@
-<html><body>Package for testing classes.</body></html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/FileUtils.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/FileUtils.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/FileUtils.java
index 22f8a9d..e0e6afa 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/FileUtils.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/FileUtils.java
@@ -24,8 +24,10 @@ import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintWriter;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -98,6 +100,7 @@ public class FileUtils
     public static void copyFile( File srcFile, File dest )
         throws IOException
     {
+        System.out.println( "Creating " + dest.getAbsolutePath() );
         byte[] buffer = new byte[ 100000 ];
         try (BufferedInputStream in = new BufferedInputStream( new FileInputStream( srcFile ) ))
         {
@@ -112,4 +115,31 @@ public class FileUtils
             }
         }
     }
+
+    public static PrintWriter createJavaClassPrintWriter( Map<String, String> properties,
+                                                          String module,
+                                                          String packagename,
+                                                          String classname
+    )
+        throws IOException
+    {
+        File projectDir = new File( properties.get( "project.dir" ) );
+        File packageDir = new File( projectDir, module + "/src/main/java/" + packagename );
+        if( !packageDir.exists() )
+        {
+            if( !packageDir.mkdirs() )
+            {
+                System.err.println( "Unable to create directory: " + packageDir.getAbsolutePath() );
+            }
+        }
+        final File destination = new File( packageDir, classname + ".java" );
+        return new PrintWriter( new FileWriter( destination ) ){
+            @Override
+            public void close()
+            {
+                super.close();
+                System.out.println("Creating " + destination );
+            }
+        };
+    }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/Main.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/Main.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/Main.java
index a5eeb6d..8dfcc60 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/Main.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/Main.java
@@ -38,8 +38,10 @@ public class Main
 
     private Main()
     {
-        addCommand( new HelpCommand() );
+        HelpCommand helpCommand = new HelpCommand();
+        addCommand( helpCommand );
         addCommand( new CreateProject() );
+        helpCommand.setCommands( commands.values() );
     }
 
     private void addCommand( Command command )
@@ -51,7 +53,7 @@ public class Main
     {
         if( !contains( args, "-q" ) )
         {
-            System.out.println( "Zest - Classes are Dead. Long Live Interfaces!" );
+            System.out.println( "\n\nZest - Classes are Dead. Long Live Interfaces!" );
             System.out.println( "----------------------------------------------\n" );
         }
         if( args.length == 0 )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
index 87a6dc4..e023be4 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
@@ -22,6 +22,9 @@ package org.apache.zest.tools.shell.create.project;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.PosixFilePermissions;
 import java.util.Map;
 import org.apache.zest.tools.shell.FileUtils;
 
@@ -38,6 +41,18 @@ abstract class AbstractProjectCreator
     {
         File templateDir = new File( properties.get( "zest.home" ), properties.get( "template.dir" ) );
         copyFiles( templateDir, projectDir, properties.get( "root.package" ) );
+        Path gradlew = new File( projectDir, "gradlew" ).toPath();
+        try
+        {
+            Files.setPosixFilePermissions( gradlew, PosixFilePermissions.fromString( "rwxr-xr-x" ) );
+        }
+        catch( Exception e )
+        {
+            if( ! System.getProperty( "os.name" ).contains( "Windows" ))
+            {
+                throw new IOException( "Unable to set file permissions on " + gradlew.toString(), e );
+            }
+        }
     }
 
     private void copyFiles( File fromDir, File toDir, String rootpackage )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/DefaultProjectCreator.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/DefaultProjectCreator.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/DefaultProjectCreator.java
index 7139475..a5a2ba8 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/DefaultProjectCreator.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/DefaultProjectCreator.java
@@ -40,9 +40,9 @@ import org.apache.zest.tools.shell.create.project.common.OrderWriter;
 import org.apache.zest.tools.shell.create.project.common.SecurityModuleWriter;
 import org.apache.zest.tools.shell.create.project.common.SecurityRepositoryWriter;
 import org.apache.zest.tools.shell.create.project.common.SerializationModuleWriter;
-import org.apache.zest.tools.shell.create.project.common.SettingsWriter;
 import org.apache.zest.tools.shell.create.project.common.StorageModuleWriter;
 import org.apache.zest.tools.shell.create.project.defaultp.ApplicationWriter;
+import org.apache.zest.tools.shell.create.project.defaultp.SettingsWriter;
 
 public class DefaultProjectCreator extends AbstractProjectCreator
     implements ProjectCreator

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/RestProjectCreator.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/RestProjectCreator.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/RestProjectCreator.java
index ec54ee2..b537a57 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/RestProjectCreator.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/RestProjectCreator.java
@@ -42,7 +42,7 @@ import org.apache.zest.tools.shell.create.project.common.OrderModuleWriter;
 import org.apache.zest.tools.shell.create.project.common.SecurityModuleWriter;
 import org.apache.zest.tools.shell.create.project.common.SecurityRepositoryWriter;
 import org.apache.zest.tools.shell.create.project.common.SerializationModuleWriter;
-import org.apache.zest.tools.shell.create.project.common.SettingsWriter;
+import org.apache.zest.tools.shell.create.project.restapp.SettingsWriter;
 import org.apache.zest.tools.shell.create.project.restapp.SimpleEnrolerWriter;
 import org.apache.zest.tools.shell.create.project.restapp.SimpleVerifierWriter;
 import org.apache.zest.tools.shell.create.project.common.StorageModuleWriter;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/SingletonProjectCreator.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/SingletonProjectCreator.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/SingletonProjectCreator.java
index 4cf990a..0ec6683 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/SingletonProjectCreator.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/SingletonProjectCreator.java
@@ -23,6 +23,7 @@ package org.apache.zest.tools.shell.create.project;
 import java.io.File;
 import java.io.IOException;
 import java.util.Map;
+import org.apache.zest.tools.shell.create.project.singleton.SettingsWriter;
 import org.apache.zest.tools.shell.create.project.singleton.SingletonApplicationAssemblerWriter;
 
 public class SingletonProjectCreator extends AbstractProjectCreator
@@ -35,5 +36,6 @@ public class SingletonProjectCreator extends AbstractProjectCreator
     {
         super.create( projectName, projectDir, properties );    // creates the directory structures.
         new SingletonApplicationAssemblerWriter().writeClass( properties );
+        new SettingsWriter().writeClass( properties );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ApplicationAssemblerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ApplicationAssemblerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ApplicationAssemblerWriter.java
index 0ab880a..33f4035 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ApplicationAssemblerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ApplicationAssemblerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class ApplicationAssemblerWriter
 {
@@ -68,29 +67,29 @@ public class ApplicationAssemblerWriter
             pw.println( "\";" );
             pw.println( "    private static final String VERSION = \"1.0.alpha\";" );
             pw.println();
-            pw.print("    public ");
+            pw.print( "    public " );
             pw.print( projectName );
-            pw.println("ApplicationAssembler( Application.Mode mode )");
-            pw.println("    throws AssemblyException");
-            pw.println("    {");
-            pw.println("        super( NAME, VERSION, mode );");
-            pw.println("    }");
+            pw.println( "ApplicationAssembler( Application.Mode mode )" );
+            pw.println( "    throws AssemblyException" );
+            pw.println( "    {" );
+            pw.println( "        super( NAME, VERSION, mode );" );
+            pw.println( "    }" );
             pw.println();
-            pw.println("    @Override");
-            pw.println("    protected void assembleLayers( ApplicationAssembly assembly )");
-            pw.println("        throws AssemblyException");
-            pw.println("    {");
-            pw.println("        LayerAssembly configLayer = createLayer( ConfigurationLayer.class );");
-            pw.println("        ModuleAssembly configModule = assemblerOf( ConfigurationLayer.class ).configModule();");
-            pw.println("        LayerAssembly domainLayer = createLayer( DomainLayer.class );");
-            pw.println("        Function<Application, Module> typeFinder = DomainLayer.typeFinder();");
-            pw.println("        LayerAssembly infraLayer = new InfrastructureLayer( configModule, typeFinder ).assemble( assembly.layer( InfrastructureLayer.NAME ) );");
-            pw.println("        LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class );");
-            pw.println("        connectivityLayer.uses( domainLayer );");
-            pw.println("        domainLayer.uses( infraLayer );");
-            pw.println("        infraLayer.uses( configLayer );");
-            pw.println("    }");
-            pw.println("}");
+            pw.println( "    @Override" );
+            pw.println( "    protected void assembleLayers( ApplicationAssembly assembly )" );
+            pw.println( "        throws AssemblyException" );
+            pw.println( "    {" );
+            pw.println( "        LayerAssembly configLayer = createLayer( ConfigurationLayer.class );" );
+            pw.println( "        ModuleAssembly configModule = assemblerOf( ConfigurationLayer.class ).configModule();" );
+            pw.println( "        LayerAssembly domainLayer = createLayer( DomainLayer.class );" );
+            pw.println( "        Function<Application, Module> typeFinder = DomainLayer.typeFinder();" );
+            pw.println( "        LayerAssembly infraLayer = new InfrastructureLayer( configModule, typeFinder ).assemble( assembly.layer( InfrastructureLayer.NAME ) );" );
+            pw.println( "        LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class );" );
+            pw.println( "        connectivityLayer.uses( domainLayer );" );
+            pw.println( "        domainLayer.uses( infraLayer );" );
+            pw.println( "        infraLayer.uses( configLayer );" );
+            pw.println( "    }" );
+            pw.println( "}" );
         }
     }
 
@@ -99,7 +98,7 @@ public class ApplicationAssemblerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/";
         String classname = properties.get( "project.name" ) + "ApplicationAssembler";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ));
+
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigLayerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigLayerWriter.java
index e79ae20..047b693 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigLayerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigLayerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class ConfigLayerWriter
 {
@@ -75,7 +74,6 @@ public class ConfigLayerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/config/";
         String classname = "ConfigurationLayer";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigModuleWriter.java
index 0c792e3..4093d5d 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConfigModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class ConfigModuleWriter
 {
@@ -71,7 +70,6 @@ public class ConfigModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/config/";
         String classname = "ConfigModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConnectivityLayerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConnectivityLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConnectivityLayerWriter.java
index 98ea384..987b03d 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConnectivityLayerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/ConnectivityLayerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class ConnectivityLayerWriter
 {
@@ -68,7 +67,6 @@ public class ConnectivityLayerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/connectivity/";
         String classname = "ConnectivityLayer";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CrudModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CrudModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CrudModuleWriter.java
index 3d8904e..5a6833b 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CrudModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CrudModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class CrudModuleWriter
 {
@@ -68,7 +67,6 @@ public class CrudModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/";
         String classname = "CrudModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CustomerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CustomerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CustomerWriter.java
index accc7e6..44b9d4b 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CustomerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/CustomerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class CustomerWriter
 {
@@ -62,7 +61,6 @@ public class CustomerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/orders/";
         String classname = "Customer";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "model", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java
index f3fe430..4041416 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class DomainLayerWriter
 {
@@ -76,7 +75,6 @@ public class DomainLayerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/";
         String classname = "DomainLayer";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java
index dca5052..3453f6d 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class FileConfigurationModuleWriter
 {
@@ -70,7 +69,6 @@ public class FileConfigurationModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/";
         String classname = "FileConfigurationModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java
index a1e1fb9..a298cec 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class HardCodedSecurityRepositoryMixinWriter
 {
@@ -81,7 +80,6 @@ public class HardCodedSecurityRepositoryMixinWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/security/";
         String classname = "HardcodedSecurityRepositoryMixin";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "model", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java
index 20790a9..78cd08c 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class IndexingModuleWriter
 {
@@ -80,7 +79,6 @@ public class IndexingModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/";
         String classname = "IndexingModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java
index 9da967f..022adab 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class InfrastructureLayerWriter
 {
@@ -85,7 +84,6 @@ public class InfrastructureLayerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/";
         String classname = "InfrastructureLayer";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java
index 28f22b8..5748ef0 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class OrderItemWriter
 {
@@ -60,7 +59,6 @@ public class OrderItemWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/orders/";
         String classname = "OrderItem";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "model", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
index 47d22a9..aec0d31 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -79,7 +78,6 @@ public class OrderModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/";
         String classname = "OrderModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java
index 550f0ec..58a7649 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class OrderWriter
 {
@@ -65,7 +64,6 @@ public class OrderWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/orders/";
         String classname = "Order";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "model", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java
index 3f576f1..4ff0297 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -82,7 +81,6 @@ public class SecurityModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/";
         String classname = "SecurityModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java
index 989811f..04b03f2 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -65,7 +64,6 @@ public class SecurityRepositoryWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/security/";
         String classname = "SecurityRepository";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "model", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java
index 6dba0de..1b042fb 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class SerializationModuleWriter
 {
@@ -84,7 +83,6 @@ public class SerializationModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/";
         String classname = "SerializationModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java
deleted file mode 100644
index ddfa388..0000000
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-
-package org.apache.zest.tools.shell.create.project.common;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Map;
-
-public class SettingsWriter
-{
-
-    public void writeClass( Map<String, String> properties )
-        throws IOException
-    {
-        String rootPackage = properties.get( "root.package" );
-        String projectName = properties.get( "project.name" );
-        try (PrintWriter pw = createPrinter( properties ))
-        {
-            pw.println(
-                String.format(
-                "\n" +
-                "include 'app',\n" +
-                "        'bootstrap',\n" +
-                "        'model',\n" +
-                "        'rest'\n" +
-                "\n" +
-                "rootProject.name = \"%s\"\n" +
-                "\n" +
-                "validateProject(rootProject, \"\")\n" +
-                "\n" +
-                "def validateProject(project, parentName)\n" +
-                "{\n" +
-                "  assert project.projectDir.isDirectory()\n" +
-                "  if( new File(\"$project.projectDir/src/main/java\").exists() )\n" +
-                "  {\n" +
-                "    assert project.buildFile.isFile()\n" +
-                "  }\n" +
-                "  if( parentName.length() > 0 )\n" +
-                "  println \"Project: \" + project.name\n" +
-                "  project.children.each { child ->\n" +
-                "    validateProject(child, project.name)\n" +
-                "  }\n" +
-                "}\n" +
-                "\n", projectName
-                ));
-        }
-    }
-
-    private PrintWriter createPrinter( Map<String, String> properties )
-        throws IOException
-    {
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "settings.gradle" ) ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java
index c9123a8..8d8f8c8 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.common;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class StorageModuleWriter
 {
@@ -81,7 +80,6 @@ public class StorageModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/";
         String classname = "StorageModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java
index 8d71c50..306aa50 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.defaultp;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -98,7 +97,6 @@ public class ApplicationWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/app/";
         String classname = properties.get("project.name");
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "app/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "app", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/SettingsWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/SettingsWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/SettingsWriter.java
new file mode 100644
index 0000000..2184b85
--- /dev/null
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/SettingsWriter.java
@@ -0,0 +1,80 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.tools.shell.create.project.defaultp;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+public class SettingsWriter
+{
+
+    public void writeClass( Map<String, String> properties )
+        throws IOException
+    {
+        String projectName = properties.get( "project.name" );
+        try (PrintWriter pw = createPrinter( properties ))
+        {
+            pw.println(
+                String.format(
+                    "\n" +
+                    "include 'app',\n" +
+                    "        'bootstrap',\n" +
+                    "        'model'\n" +
+                    "\n" +
+                    "rootProject.name = \"%s\"\n" +
+                    "\n" +
+                    "validateProject(rootProject, \"\")\n" +
+                    "\n" +
+                    "def validateProject(project, parentName)\n" +
+                    "{\n" +
+                    "  assert project.projectDir.isDirectory()\n" +
+                    "  if( new File(\"$project.projectDir/src/main/java\").exists() )\n" +
+                    "  {\n" +
+                    "    assert project.buildFile.isFile()\n" +
+                    "  }\n" +
+                    "  if( parentName.length() > 0 )\n" +
+                    "  println \"Project: \" + project.name\n" +
+                    "  project.children.each { child ->\n" +
+                    "    validateProject(child, project.name)\n" +
+                    "  }\n" +
+                    "}\n" +
+                    "\n", projectName
+                ) );
+        }
+    }
+
+    private PrintWriter createPrinter( Map<String, String> properties )
+        throws IOException
+    {
+        File projectDir = new File( properties.get( "project.dir" ) );
+        if( !projectDir.exists() )
+        {
+            if( !projectDir.mkdirs() )
+            {
+                System.err.println( "Unable to create directory: " + projectDir.getAbsolutePath() );
+            }
+        }
+        return new PrintWriter( new FileWriter( new File( projectDir, "settings.gradle" ) ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
index b4a2bcc..24c2a08 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.restapp;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -128,7 +127,6 @@ public class ApplicationWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/app/";
         String classname = properties.get("project.name");
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "app/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "app", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/IndexHtmlWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/IndexHtmlWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/IndexHtmlWriter.java
index ba8f446..a2143b5 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/IndexHtmlWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/IndexHtmlWriter.java
@@ -51,7 +51,15 @@ public class IndexHtmlWriter
         throws IOException
     {
         File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "app/src/main/webapp/index.html" ) ) );
+        File destDir = new File( projectDir, "app/src/main/webapp" );
+        if( !destDir.exists() )
+        {
+            if( !destDir.mkdirs() )
+            {
+                System.err.println( "Unable to create directory: " + destDir.getAbsolutePath() );
+            }
+        }
+        return new PrintWriter( new FileWriter( new File( destDir, "index.html" ) ) );
     }
 }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/RestModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/RestModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/RestModuleWriter.java
index 601347d..f8d849f 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/RestModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/RestModuleWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.restapp;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -81,7 +80,6 @@ public class RestModuleWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/connectivity/";
         String classname = "RestModule";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "bootstrap", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SettingsWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SettingsWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SettingsWriter.java
new file mode 100644
index 0000000..e906ca6
--- /dev/null
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SettingsWriter.java
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.tools.shell.create.project.restapp;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+public class SettingsWriter
+{
+
+    public void writeClass( Map<String, String> properties )
+        throws IOException
+    {
+        String projectName = properties.get( "project.name" );
+        try (PrintWriter pw = createPrinter( properties ))
+        {
+            pw.println(
+                String.format(
+                    "\n" +
+                    "include 'app',\n" +
+                    "        'bootstrap',\n" +
+                    "        'model',\n" +
+                    "        'rest'\n" +
+                    "\n" +
+                    "rootProject.name = \"%s\"\n" +
+                    "\n" +
+                    "validateProject(rootProject, \"\")\n" +
+                    "\n" +
+                    "def validateProject(project, parentName)\n" +
+                    "{\n" +
+                    "  assert project.projectDir.isDirectory()\n" +
+                    "  if( new File(\"$project.projectDir/src/main/java\").exists() )\n" +
+                    "  {\n" +
+                    "    assert project.buildFile.isFile()\n" +
+                    "  }\n" +
+                    "  if( parentName.length() > 0 )\n" +
+                    "  println \"Project: \" + project.name\n" +
+                    "  project.children.each { child ->\n" +
+                    "    validateProject(child, project.name)\n" +
+                    "  }\n" +
+                    "}\n" +
+                    "\n", projectName
+                ) );
+        }
+    }
+
+    private PrintWriter createPrinter( Map<String, String> properties )
+        throws IOException
+    {
+        File projectDir = new File( properties.get( "project.dir" ) );
+        if( !projectDir.exists() )
+        {
+            if( !projectDir.mkdirs() )
+            {
+                System.err.println( "Unable to create directory: " + projectDir.getAbsolutePath() );
+            }
+        }
+        return new PrintWriter( new FileWriter( new File( projectDir, "settings.gradle" ) ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleEnrolerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleEnrolerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleEnrolerWriter.java
index 1287278..6e44b01 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleEnrolerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleEnrolerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.restapp;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -82,7 +81,6 @@ public class SimpleEnrolerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/rest/security/";
         String classname = "SimpleEnroler";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "rest/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "rest", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleVerifierWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleVerifierWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleVerifierWriter.java
index b928f5d..c1ff1a5 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleVerifierWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/SimpleVerifierWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.restapp;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -76,7 +75,6 @@ public class SimpleVerifierWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/rest/security/";
         String classname = "SimpleVerifier";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "rest/src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "rest", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/WebXmlWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/WebXmlWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/WebXmlWriter.java
index 61b941c..d67de80 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/WebXmlWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/WebXmlWriter.java
@@ -49,7 +49,7 @@ public class WebXmlWriter
                     "    <servlet-name>zestrest</servlet-name>\n" +
                     "    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>\n" +
                     "    <init-param>\n" +
-                    "      <param-name>org.sensorsink.kooda.mode</param-name>\n" +
+                    "      <param-name>org.apache.zest.runtime.mode</param-name>\n" +
                     "      <param-value>production</param-value>\n" +
                     "    </init-param>\n" +
                     "    <init-param>\n" +
@@ -79,7 +79,15 @@ public class WebXmlWriter
         throws IOException
     {
         File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "app/src/main/webapp/WEB-INF/web.xml" ) ) );
+        File destDir = new File( projectDir, "app/src/main/webapp/WEB-INF" );
+        if( !destDir.exists() )
+        {
+            if( !destDir.mkdirs() )
+            {
+                System.err.println( "Unable to create directory: " + destDir.getAbsolutePath() );
+            }
+        }
+        return new PrintWriter( new FileWriter( new File( destDir, "web.xml" ) ) );
     }
 }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SettingsWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SettingsWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SettingsWriter.java
new file mode 100644
index 0000000..2d3123d
--- /dev/null
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SettingsWriter.java
@@ -0,0 +1,76 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.tools.shell.create.project.singleton;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+public class SettingsWriter
+{
+
+    public void writeClass( Map<String, String> properties )
+        throws IOException
+    {
+        String projectName = properties.get( "project.name" );
+        try (PrintWriter pw = createPrinter( properties ))
+        {
+            pw.println(
+                String.format(
+                    "\n" +
+                    "rootProject.name = \"%s\"\n" +
+                    "\n" +
+                    "validateProject(rootProject, \"\")\n" +
+                    "\n" +
+                    "def validateProject(project, parentName)\n" +
+                    "{\n" +
+                    "  assert project.projectDir.isDirectory()\n" +
+                    "  if( new File(\"$project.projectDir/src/main/java\").exists() )\n" +
+                    "  {\n" +
+                    "    assert project.buildFile.isFile()\n" +
+                    "  }\n" +
+                    "  if( parentName.length() > 0 )\n" +
+                    "  println \"Project: \" + project.name\n" +
+                    "  project.children.each { child ->\n" +
+                    "    validateProject(child, project.name)\n" +
+                    "  }\n" +
+                    "}\n" +
+                    "\n", projectName
+                ) );
+        }
+    }
+
+    private PrintWriter createPrinter( Map<String, String> properties )
+        throws IOException
+    {
+        File projectDir = new File( properties.get( "project.dir" ) );
+        if( !projectDir.exists() )
+        {
+            if( !projectDir.mkdirs() )
+            {
+                System.err.println( "Unable to create directory: " + projectDir.getAbsolutePath() );
+            }
+        }
+        return new PrintWriter( new FileWriter( new File( projectDir, "settings.gradle" ) ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SingletonApplicationAssemblerWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SingletonApplicationAssemblerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SingletonApplicationAssemblerWriter.java
index 8a125a7..df66321 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SingletonApplicationAssemblerWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/SingletonApplicationAssemblerWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.singleton;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 import static java.lang.String.format;
 
@@ -99,7 +98,6 @@ public class SingletonApplicationAssemblerWriter
     {
         String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" );
         String classname = properties.get("project.name");
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/StartupServiceWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/StartupServiceWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/StartupServiceWriter.java
index 669821c..b07817f 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/StartupServiceWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/singleton/StartupServiceWriter.java
@@ -20,11 +20,10 @@
 
 package org.apache.zest.tools.shell.create.project.singleton;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import org.apache.zest.tools.shell.FileUtils;
 
 public class StartupServiceWriter
 {
@@ -62,9 +61,8 @@ public class StartupServiceWriter
     private PrintWriter createPrinter( Map<String, String> properties )
         throws IOException
     {
-        String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" );
+        String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/";
         String classname = "StartupService";
-        File projectDir = new File( properties.get( "project.dir" ) );
-        return new PrintWriter( new FileWriter( new File( projectDir, "src/main/java/" + packagename + classname + ".java" ) ) );
+        return FileUtils.createJavaClassPrintWriter( properties, "", packagename, classname );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/main/java/org/apache/zest/tools/shell/help/HelpCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/help/HelpCommand.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/help/HelpCommand.java
index 814a755..abed33d 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/help/HelpCommand.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/help/HelpCommand.java
@@ -32,7 +32,7 @@ public class HelpCommand extends AbstractCommand
     {
     }
 
-    public void setCommands( Iterable<Command> comands )
+    public void setCommands( Iterable<Command> commands )
     {
         this.commands = commands;
     }
@@ -42,19 +42,21 @@ public class HelpCommand extends AbstractCommand
     {
         for( Command command : commands )
         {
-            output.println( command.name() + " " + command.description() );
+            String text = command.name() + " " + command.description();
+            output.println( text );
+            output.flush();
         }
     }
 
     @Override
     public String description()
     {
-        return "help";
+        return "\t\t\t\t\tPrints this help text.";
     }
 
     @Override
     public String name()
     {
-        return "Prints this help text.";
+        return "help";
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/54c1e612/tools/shell/src/test/java/org/apache/zest/tools/shell/HelpCommandTest.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/test/java/org/apache/zest/tools/shell/HelpCommandTest.java b/tools/shell/src/test/java/org/apache/zest/tools/shell/HelpCommandTest.java
new file mode 100644
index 0000000..5c15593
--- /dev/null
+++ b/tools/shell/src/test/java/org/apache/zest/tools/shell/HelpCommandTest.java
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.tools.shell;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.zest.tools.shell.create.CreateProject;
+import org.apache.zest.tools.shell.help.HelpCommand;
+import org.junit.Test;
+
+public class HelpCommandTest
+{
+    @Test
+    public void givenTwoCommandsWhenExecutingHelpExpectExplanation(){
+        HelpCommand underTest = new HelpCommand();
+        List<Command> commands = Arrays.asList( underTest, new CreateProject() );
+        underTest.setCommands( commands );
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(  );
+        PrintWriter pw = new PrintWriter( baos );
+        underTest.execute( null, null, pw );
+        System.out.println(baos.toString());
+    }
+}


Mime
View raw message