Author: massi
Date: Fri Aug  8 15:51:00 2014
New Revision: 1616809

URL: http://svn.apache.org/r1616809
Log:
Fixed #SYNCOPE-542

Added:
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/InstallLog.java
Modified:
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/jboss/JBoss.java
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ContainerProcess.java
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/HttpUtils.java
    
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
 Fri Aug  8 15:51:00 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.installer.containers;
 
+import com.izforge.izpack.panels.process.AbstractUIProcessHandler;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import org.apache.syncope.installer.utilities.FileSystemUtils;
@@ -32,14 +33,15 @@ public class Tomcat extends AbstractCont
     private final String installPath;
 
     private final String artifactId;
-
+    
     private final HttpUtils httpUtils;
 
     public Tomcat(final boolean tomcatSsl, final String tomcatHost, final 
String tomcatPort,
-            final String installPath, final String artifactId, final String 
tomcatUser, final String tomcatPassword) {
+            final String installPath, final String artifactId, final String 
tomcatUser, final String tomcatPassword,
+            final AbstractUIProcessHandler handler) {
         this.installPath = installPath;
         this.artifactId = artifactId;
-        httpUtils = new HttpUtils(tomcatSsl, tomcatHost, tomcatPort, 
tomcatUser, tomcatPassword);
+        httpUtils = new HttpUtils(tomcatSsl, tomcatHost, tomcatPort, 
tomcatUser, tomcatPassword, handler);
     }
 
     public boolean deployCore() {

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/jboss/JBoss.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/jboss/JBoss.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/jboss/JBoss.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/jboss/JBoss.java
 Fri Aug  8 15:51:00 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.installer.containers.jboss;
 
+import com.izforge.izpack.panels.process.AbstractUIProcessHandler;
 import org.apache.syncope.installer.containers.AbstractContainer;
 import org.apache.syncope.installer.utilities.HttpUtils;
 import org.apache.syncope.installer.utilities.JsonUtils;
@@ -42,13 +43,13 @@ public class JBoss extends AbstractConta
 
     public JBoss(final boolean jbossSsl, final String jbossHost, final String 
jbossPort,
             final String jbossAdminUsername, final String jbossAdminPassword,
-            final String installPath, final String artifactId) {
+            final String installPath, final String artifactId, final 
AbstractUIProcessHandler handler) {
         this.jbossSsl = jbossSsl;
         this.jbossHost = jbossHost;
         this.jbossPort = jbossPort;
         this.installPath = installPath;
         this.artifactId = artifactId;
-        httpUtils = new HttpUtils(jbossSsl, jbossHost, jbossPort, 
jbossAdminUsername, jbossAdminPassword);
+        httpUtils = new HttpUtils(jbossSsl, jbossHost, jbossPort, 
jbossAdminUsername, jbossAdminPassword, handler);
 
     }
 

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
 Fri Aug  8 15:51:00 2014
@@ -22,6 +22,7 @@ import org.apache.syncope.installer.util
 import com.izforge.izpack.panels.process.AbstractUIProcessHandler;
 import java.io.File;
 import org.apache.syncope.installer.files.Pom;
+import org.apache.syncope.installer.utilities.InstallLog;
 import org.apache.syncope.installer.utilities.MavenUtils;
 
 public class ArchetypeProcess {
@@ -44,6 +45,7 @@ public class ArchetypeProcess {
 
         if (!new File(installPath).exists()) {
             fileSystemUtils.createDirectory(installPath, null);
+            InstallLog.initialize(installPath, handler);
         }
 
         final MavenUtils mavenUtils = new MavenUtils(mavenDir, handler);

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ContainerProcess.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ContainerProcess.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ContainerProcess.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ContainerProcess.java
 Fri Aug  8 15:51:00 2014
@@ -29,6 +29,7 @@ import org.apache.syncope.installer.file
 import org.apache.syncope.installer.files.JBossDeploymentStructureXml;
 import org.apache.syncope.installer.files.PersistenceContextEMFactoryXml;
 import org.apache.syncope.installer.files.CoreWebXml;
+import org.apache.syncope.installer.utilities.InstallLog;
 import org.apache.syncope.installer.utilities.MavenUtils;
 
 public class ContainerProcess {
@@ -96,6 +97,9 @@ public class ContainerProcess {
 
         final FileSystemUtils fileSystemUtils = new FileSystemUtils(handler);
 
+        handler.logOutput("Configure web.xml file according to " + 
selectedContainer + " properties", true);
+        InstallLog.getInstance().info("Configure web.xml file according to " + 
selectedContainer + " properties");
+
         if (withDataSource) {
             fileSystemUtils.writeToFile(new File(installPath + "/" + 
artifactId + CoreWebXml.PATH), CoreWebXml.
                     withDataSource());
@@ -122,37 +126,50 @@ public class ContainerProcess {
         switch (selectedContainer) {
             case TOMCAT:
                 final Tomcat tomcat = new Tomcat(
-                        tomcatSsl, tomcatHost, tomcatPort, installPath, 
artifactId, tomcatUser, tomcatPassword);
+                        tomcatSsl, tomcatHost, tomcatPort, installPath, 
artifactId, tomcatUser, tomcatPassword, handler);
                 boolean deployCoreResult = tomcat.deployCore();
                 if (deployCoreResult) {
                     handler.logOutput("Core successfully deployed ", true);
+                    InstallLog.getInstance().info("Core successfully deployed 
");
                 } else {
-                    handler.emitError("Deploy core on Tomcat failed", "Deploy 
core on Tomcat failed");
+                    final String messageError = "Deploy core on Tomcat failed";
+                    handler.emitError(messageError, messageError);
+                    InstallLog.getInstance().error(messageError);
                 }
 
                 boolean deployConsoleResult = tomcat.deployConsole();
                 if (deployConsoleResult) {
                     handler.logOutput("Console successfully deployed ", true);
+                    InstallLog.getInstance().info("Console successfully 
deployed ");
                 } else {
-                    handler.emitError("Deploy console on Tomcat failed", 
"Deploy console on Tomcat failed");
+                    final String messageError = "Deploy console on Tomcat 
failed";
+                    handler.emitError(messageError, messageError);
+                    InstallLog.getInstance().error(messageError);
                 }
                 break;
             case JBOSS:
                 final JBoss jBoss = new JBoss(
-                        jbossSsl, jbossHost, jbossPort, jbossAdminUsername, 
jbossAdminPassword, installPath, artifactId);
+                        jbossSsl, jbossHost, jbossPort, jbossAdminUsername,
+                        jbossAdminPassword, installPath, artifactId, handler);
 
                 boolean deployCoreJboss = jBoss.deployCore();
                 if (deployCoreJboss) {
                     handler.logOutput("Core successfully deployed ", true);
+                    InstallLog.getInstance().info("Core successfully deployed 
");
                 } else {
-                    handler.emitError("Deploy core on JBoss failed", "Deploy 
core on JBoss failed");
+                    final String messageError = "Deploy core on JBoss failed";
+                    handler.emitError(messageError, messageError);
+                    InstallLog.getInstance().error(messageError);
                 }
 
                 boolean deployConsoleJBoss = jBoss.deployConsole();
                 if (deployConsoleJBoss) {
                     handler.logOutput("Console successfully deployed ", true);
+                    InstallLog.getInstance().info("Console successfully 
deployed ");
                 } else {
-                    handler.emitError("Deploy console on JBoss failed", 
"Deploy console on JBoss failed");
+                    final String messageError = "Deploy console on JBoss 
failed";
+                    handler.emitError(messageError, messageError);
+                    InstallLog.getInstance().error(messageError);
                 }
                 break;
             case GLASSFISH:

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
 Fri Aug  8 15:51:00 2014
@@ -24,6 +24,7 @@ import java.io.File;
 import org.apache.syncope.installer.enums.DBs;
 import org.apache.syncope.installer.files.OrmXml;
 import org.apache.syncope.installer.files.PersistenceProperties;
+import org.apache.syncope.installer.utilities.InstallLog;
 
 public class PersistenceProcess {
 
@@ -58,6 +59,9 @@ public class PersistenceProcess {
 
         final StringBuilder persistenceProperties = new 
StringBuilder(PersistenceProperties.HEADER);
 
+        handler.logOutput("Configure persistence file according to " + 
dbSelected + " properties", true);
+        InstallLog.getInstance().info("Configure persistence file according to 
" + dbSelected + " properties");
+        
         switch (dbSelected) {
             case POSTGRES:
                 persistenceProperties.append(String.format(

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java
 Fri Aug  8 15:51:00 2014
@@ -26,25 +26,34 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.PrintWriter;
 
 public class FileSystemUtils {
 
     public static final boolean IS_WIN = 
System.getProperty("os.name").toLowerCase().contains("win");
 
+    private static final String UNIX_CREATE_DIRECTORY = "mkdir -p %s";
+
+    private static final String WIN_CREATE_DIRECTORY = "mkdir %s";
+
     private final AbstractUIProcessHandler handler;
-    
+
     public FileSystemUtils(final AbstractUIProcessHandler handler) {
         this.handler = handler;
     }
-    
+
     public void createDirectory(final String directoryPath, final String path) 
{
-        exec(String.format(CREATE_DIRECTORY, directoryPath), path);
-    }
+        if (IS_WIN) {
+            exec(String.format(WIN_CREATE_DIRECTORY, directoryPath), path);
+        } else {
+            exec(String.format(UNIX_CREATE_DIRECTORY, directoryPath), path);
+        }
 
-    private static final String CREATE_DIRECTORY = "mkdir -p %s";
+    }
 
     public void exec(final String cmd, final String path) {
         try {
+            handler.logOutput("Executing " + cmd, true);
             final ProcessBuilder builder = new ProcessBuilder(cmd.split(" "));
             if (path != null && !path.isEmpty()) {
                 builder.directory(new File(path));
@@ -52,8 +61,9 @@ public class FileSystemUtils {
             final Process process = builder.start();
             readResponse(process.getInputStream());
         } catch (final IOException ex) {
-            handler.emitError("Error executing " + cmd + ": " + 
ex.getMessage(),
-                    "Error executing " + cmd + ": " + ex.getMessage());
+            final String errorMessage = "Error executing " + cmd + ": " + 
ex.getMessage();
+            handler.emitError(errorMessage, errorMessage);
+            InstallLog.getInstance().error(errorMessage);
         }
     }
 
@@ -63,7 +73,9 @@ public class FileSystemUtils {
         String line = reader.readLine();
         while (line != null) {
             line = reader.readLine();
-            handler.logOutput(line == null ? "" : line, false);
+            final String content = line == null ? "" : line;
+            handler.logOutput(content, false);
+            InstallLog.getInstance().info(content);
         }
         inputStream.close();
     }
@@ -75,8 +87,24 @@ public class FileSystemUtils {
             bw.write(content);
             bw.close();
         } catch (final IOException ex) {
-            handler.emitError("Error writing file" + file.getAbsolutePath() + 
": " + ex.getMessage(),
-                    "Error writing file" + file.getAbsolutePath() + ": " + 
ex.getMessage());
+            final String errorMessage = "Error writing file " + 
file.getAbsolutePath() + ": " + ex.getMessage();
+            handler.emitError(errorMessage, errorMessage);
+            InstallLog.getInstance().error(errorMessage);
+        }
+    }
+
+    public void appendToFile(final File file, final String content) {
+        try {
+            if (!file.exists()) {
+                file.createNewFile();
+            }
+            final PrintWriter out = new PrintWriter(new BufferedWriter(new 
FileWriter(file, true)));
+            out.println(content);
+            out.close();
+        } catch (IOException ex) {
+            final String errorMessage = "Error writing file " + 
file.getAbsolutePath() + ": " + ex.getMessage();
+            handler.emitError(errorMessage, errorMessage);
+            InstallLog.getInstance().error(errorMessage);
         }
     }
 

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/HttpUtils.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/HttpUtils.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/HttpUtils.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/HttpUtils.java
 Fri Aug  8 15:51:00 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.installer.utilities;
 
+import com.izforge.izpack.panels.process.AbstractUIProcessHandler;
 import java.io.File;
 import java.io.IOException;
 import java.security.KeyManagementException;
@@ -69,8 +70,10 @@ public class HttpUtils {
 
     private final HttpHost targetHost;
 
+    private final AbstractUIProcessHandler handler;
+
     public HttpUtils(final boolean isSsl, final String host,
-            final String port, final String username, final String password) {
+            final String port, final String username, final String password, 
final AbstractUIProcessHandler handler) {
 
         this.isSsl = isSsl;
         this.host = host;
@@ -83,9 +86,11 @@ public class HttpUtils {
             httpClient = HttpClients.createDefault();
             this.targetHost = new HttpHost(this.host, this.port, "http");
         }
-        
+
         this.username = username;
         this.password = password;
+
+        this.handler = handler;
     }
 
     public int getWithBasicAuth(final String path) {
@@ -97,11 +102,18 @@ public class HttpUtils {
         }
         int status = 0;
         try {
+            handler.logOutput("Calling " + httpGet.getURI(), true);
+            InstallLog.getInstance().info("Calling " + httpGet.getURI());
             final CloseableHttpResponse response = httpClient.execute(
                     targetHost, httpGet, setAuth(targetHost, new 
BasicScheme()));
             status = response.getStatusLine().getStatusCode();
+            handler.logOutput("Calling status " + status, true);
+            InstallLog.getInstance().info("Calling status " + status);
             response.close();
-        } catch (IOException ex) {
+        } catch (final IOException ex) {
+            final String messageError = "Error in " + path + ": " + 
ex.getMessage();
+            handler.emitError(messageError, messageError);
+            InstallLog.getInstance().error(messageError);
         }
         return status;
     }
@@ -113,8 +125,13 @@ public class HttpUtils {
                     httpPost(url, 
MultipartEntityBuilder.create().addPart("bin", new FileBody(new 
File(file))).build()),
                     setAuth(targetHost, new DigestScheme()));
             responseBodyAsString = 
IOUtils.toString(response.getEntity().getContent());
+            handler.logOutput("Http status: " + 
response.getStatusLine().getStatusCode(), true);
+            InstallLog.getInstance().info("Http status: " + 
response.getStatusLine().getStatusCode());
             response.close();
-        } catch (IOException ex) {
+        } catch (final IOException ex) {
+            final String messageError = "Error calling " + url + ": " + 
ex.getMessage();
+            handler.emitError(messageError, messageError);
+            InstallLog.getInstance().error(messageError);
         }
 
         return responseBodyAsString;
@@ -128,8 +145,15 @@ public class HttpUtils {
             final CloseableHttpResponse response = httpClient.execute(
                     targetHost, httPost, setAuth(targetHost, new 
DigestScheme()));
             status = response.getStatusLine().getStatusCode();
+            handler.logOutput("Http status: " + status, true);
+            InstallLog.getInstance().info("Http status: " + status);
+
             response.close();
-        } catch (IOException ioe) {
+        } catch (final IOException ioe) {
+            final String messageError = "Error calling " + url + ": " + 
ioe.getMessage();
+            handler.emitError(messageError, messageError);
+            InstallLog.getInstance().error(messageError);
+
         }
         return status;
     }
@@ -149,6 +173,8 @@ public class HttpUtils {
     private HttpPost httpPost(final String url, final HttpEntity reqEntity) {
         final HttpPost httppost = new HttpPost(url);
         httppost.setEntity(reqEntity);
+        handler.logOutput("Calling " + httppost.getURI(), true);
+        InstallLog.getInstance().info("Calling " + httppost.getURI());
         return httppost;
     }
 

Added: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/InstallLog.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/InstallLog.java?rev=1616809&view=auto
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/InstallLog.java
 (added)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/InstallLog.java
 Fri Aug  8 15:51:00 2014
@@ -0,0 +1,63 @@
+/*
+ * 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.syncope.installer.utilities;
+
+import com.izforge.izpack.panels.process.AbstractUIProcessHandler;
+import java.io.File;
+import java.util.Date;
+
+public class InstallLog {
+
+    private static InstallLog installLog = null;
+
+    private final File log;
+
+    private final FileSystemUtils fileSystemUtils;
+
+    private InstallLog(final String installPath, final 
AbstractUIProcessHandler handler) {
+        log = new File(installPath + "/install.log");
+        fileSystemUtils = new FileSystemUtils(handler);
+    }
+
+    public static InstallLog initialize(final String installPath, final 
AbstractUIProcessHandler handler) {
+        synchronized (InstallLog.class) {
+            if (installLog == null) {
+                installLog = new InstallLog(installPath, handler);
+            }
+        }
+        return installLog;
+    }
+
+    public static InstallLog getInstance() {
+        return installLog;
+    }
+
+    public void error(final String msg) {
+        writeToFile("Error", msg);
+    }
+
+    public void info(final String msg) {
+        writeToFile("Info", msg);
+    }
+
+    private void writeToFile(final String what, final String msg) {
+        fileSystemUtils.appendToFile(log, new Date() + " | " + what + ": " + 
msg);
+    }
+
+}

Modified: 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java?rev=1616809&r1=1616808&r2=1616809&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
 (original)
+++ 
syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
 Fri Aug  8 15:51:00 2014
@@ -50,7 +50,11 @@ public class MavenUtils {
         final InvocationRequest request = new DefaultInvocationRequest();
         request.setGoals(Collections.singletonList("archetype:generate"));
         request.setInteractive(false);
-        request.setProperties(archetypeProperties(archetypeVersion, groupId, 
artifactId, secretKey, anonymousKey));
+        final Properties properties
+                = archetypeProperties(archetypeVersion, groupId, artifactId, 
secretKey, anonymousKey);
+        request.setProperties(properties);
+        logToHandler(request.getGoals(), properties);
+        logToFile(request.getGoals(), properties);
         invoke(request, installPath);
     }
 
@@ -72,14 +76,41 @@ public class MavenUtils {
             final String logDirectory, final String bundlesDirectory) {
 
         final InvocationRequest request = new DefaultInvocationRequest();
-        request.setProperties(packageProperties(confDirectory, logDirectory, 
bundlesDirectory));
+        final Properties properties = packageProperties(confDirectory, 
logDirectory, bundlesDirectory);
+        request.setProperties(properties);
         final List<String> mavenGoals = new ArrayList<String>();
         mavenGoals.add("clean");
         mavenGoals.add("package");
         request.setGoals(mavenGoals);
+        logToHandler(request.getGoals(), properties);
+        logToFile(request.getGoals(), properties);
         invoke(request, path);
     }
 
+    private void logToHandler(final List<String> goals, final Properties 
properties) {
+        handler.logOutput("Executing maven command:", true);
+        final StringBuilder mavenCommand = new StringBuilder("mvn ");
+        for (final String goal : goals) {
+            mavenCommand.append(goal).append(" ");
+        }
+        handler.logOutput(mavenCommand.toString(), true);
+        for (final String propertyName : properties.stringPropertyNames()) {
+            handler.logOutput("-D " + propertyName + "=" + 
properties.getProperty(propertyName), true);
+        }
+    }
+
+    private void logToFile(final List<String> goals, final Properties 
properties) {
+        InstallLog.getInstance().info("Executing maven command:");
+        final StringBuilder mavenCommand = new StringBuilder("mvn ");
+        for (final String goal : goals) {
+            mavenCommand.append(goal).append(" ");
+        }
+        InstallLog.getInstance().info(mavenCommand.toString());
+        for (final String propertyName : properties.stringPropertyNames()) {
+            InstallLog.getInstance().info("-D " + propertyName + "=" + 
properties.getProperty(propertyName));
+        }
+    }
+
     private Properties packageProperties(final String confDirectory, final 
String logDirectory,
             final String bundlesDirectory) {
         final Properties properties = new Properties();
@@ -97,7 +128,9 @@ public class MavenUtils {
         try {
             result = invoker.execute(request);
         } catch (MavenInvocationException ex) {
-            handler.emitError("Maven exception: " + ex.getMessage(), "Maven 
exception: " + ex.getMessage());
+            final String messageError = "Maven exception: " + ex.getMessage();
+            handler.emitError(messageError, messageError);
+            InstallLog.getInstance().info(messageError);
         }
         return result;
     }


Reply via email to