continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r649337 - /continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
Date Fri, 18 Apr 2008 00:47:40 GMT
Author: carlos
Date: Thu Apr 17 17:47:38 2008
New Revision: 649337

URL: http://svn.apache.org/viewvc?rev=649337&view=rev
Log:
Refactor

Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?rev=649337&r1=649336&r2=649337&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
Thu Apr 17 17:47:38 2008
@@ -99,6 +99,26 @@
         this.resolveExecutable = resolveExecutable;
     }
 
+    public void setShellCommandHelper( ShellCommandHelper shellCommandHelper )
+    {
+        this.shellCommandHelper = shellCommandHelper;
+    }
+
+    public ShellCommandHelper getShellCommandHelper()
+    {
+        return shellCommandHelper;
+    }
+
+    public void setWorkingDirectoryService( WorkingDirectoryService workingDirectoryService
)
+    {
+        this.workingDirectoryService = workingDirectoryService;
+    }
+
+    public WorkingDirectoryService getWorkingDirectoryService()
+    {
+        return workingDirectoryService;
+    }
+
     // ----------------------------------------------------------------------
     // Component Lifecycle
     // ----------------------------------------------------------------------
@@ -137,9 +157,11 @@
     //
     // ----------------------------------------------------------------------
 
-    protected ContinuumBuildExecutionResult executeShellCommand( Project project, String
executable, String arguments,
-                                                                 File output, Map<String,
String> environments )
-        throws ContinuumBuildExecutorException
+    /**
+     * Find the actual executable path to be used
+     * @param defaultExecutable 
+     */
+    protected String findExecutable( Project project, String executable, String defaultExecutable,
boolean resolveExecutable, File workingDirectory )
     {
         // ----------------------------------------------------------------------
         // If we're not searching the path for the executable, prefix the
@@ -149,8 +171,6 @@
 
         String actualExecutable;
 
-        File workingDirectory = getWorkingDirectory( project );
-
         if ( !resolveExecutable )
         {
             actualExecutable = new File( workingDirectory, executable ).getAbsolutePath();
@@ -192,6 +212,19 @@
         {
             actualExecutable = executable;
         }
+        
+        return actualExecutable;
+    }
+
+    protected ContinuumBuildExecutionResult executeShellCommand( Project project, String
executable, String arguments,
+                                                                 File output, Map<String,
String> environments )
+        throws ContinuumBuildExecutorException
+    {
+
+        File workingDirectory = getWorkingDirectory( project );
+
+        String actualExecutable =
+            findExecutable( project, executable, defaultExecutable, resolveExecutable, workingDirectory
);
 
         // ----------------------------------------------------------------------
         // Execute the build
@@ -199,9 +232,9 @@
 
         try
         {
-            ExecutionResult result = shellCommandHelper.executeShellCommand( workingDirectory,
actualExecutable,
-                                                                             arguments, output,
project.getId(),
-                                                                             environments
);
+            ExecutionResult result =
+                getShellCommandHelper().executeShellCommand( workingDirectory, actualExecutable,
arguments, output,
+                                                             project.getId(), environments
);
 
             getLogger().info( "Exit code: " + result.getExitCode() );
 
@@ -298,12 +331,12 @@
 
     public boolean isBuilding( Project project )
     {
-        return project.getState() == ContinuumProjectState.BUILDING || shellCommandHelper.isRunning(
project.getId() );
+        return project.getState() == ContinuumProjectState.BUILDING || getShellCommandHelper().isRunning(
project.getId() );
     }
 
     public void killProcess( Project project )
     {
-        shellCommandHelper.killProcess( project.getId() );
+        getShellCommandHelper().killProcess( project.getId() );
     }
 
     public List getDeployableArtifacts( Project project, File workingDirectory, BuildDefinition
buildDefinition )
@@ -315,7 +348,7 @@
 
     public File getWorkingDirectory( Project project )
     {
-        return workingDirectoryService.getWorkingDirectory( project );
+        return getWorkingDirectoryService().getWorkingDirectory( project );
     }
 
     public InstallationService getInstallationService()



Mime
View raw message