package net.wasdev.wlp.maven.plugins.server;

import java.text.MessageFormat;

import org.codehaus.plexus.util.FileUtils;

import net.wasdev.wlp.ant.ServerTask;

/**
 * Create a liberty server
 * 
 * @goal create-server
 * 
 * 
 */
public class CreateServerMojo extends StartDebugMojoSupport {

    @Override
    protected void doExecute() throws Exception {
        if (isInstall) {
            installServerAssembly();
        } else {
            log.info(MessageFormat.format(messages.getString("info.install.type.preexisting"), ""));
            checkServerHomeExists();
        }

        boolean createServer = false;

        if (!serverDirectory.exists()) {
            createServer = true;
        } else if (refresh) {
            FileUtils.forceDelete(serverDirectory);
            createServer = true;
        }

        if (createServer) {
            // server does not exist or we are refreshing it - create it
            log.info(MessageFormat.format(messages.getString("info.server.start.create"), serverName));
            ServerTask serverTask = initializeJava();
            serverTask.setOperation("create");
            serverTask.execute();
            // copy files _after_ we create the server
            copyConfigFiles(true);
            log.info(MessageFormat.format(messages.getString("info.server.create.created"), serverName, serverDirectory.getCanonicalPath()));
        } else {
            // server exists - copy files over
            copyConfigFiles();
        }
    }
}

@@ -288,16 +288,176 @@
 port %7B%0A%0A
+    /**%0A     * Name of the template to use when creating a server.%0A     * %0A     * @parameter expression=%22$%7Btemplate%7D%22%0A     */%0A    private String template;%0A    %0A
     @Ove
@@ -1285,16 +1285,62 @@
 eate%22);%0A
+            serverTask.setTemplate(template);%0A
         

Support template parameter for create-server goal