Diff of /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builder/maven/m2/MavenShellBuilder.java
Parent Directory
| Revision Log
| Patch
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builder/maven/m2/MavenShellBuilder.java 2005/05/04 20:41:07 168186
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builder/maven/m2/MavenShellBuilder.java 2005/05/04 20:42:31 168187
@@ -18,10 +18,13 @@ package org.apache.maven.continuum.build
import java.io.File;
import java.net.URL;
-import java.util.Arrays;
import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.builder.shell.ShellBuilder;
+import org.apache.maven.continuum.builder.AbstractContinuumBuilder;
+import org.apache.maven.continuum.builder.ContinuumBuilder;
+import org.apache.maven.continuum.builder.shell.ExecutionResult;
+import org.apache.maven.continuum.builder.shell.ShellCommandHelper;
+import org.apache.maven.continuum.project.ContinuumBuildResult;
import org.apache.maven.continuum.project.ContinuumProject;
/**
@@ -29,13 +32,17 @@ import org.apache.maven.continuum.projec
* @version $Id: MavenShellBuilder.java,v 1.2 2005/04/07 23:27:39 trygvis Exp $
*/
public class MavenShellBuilder
- extends ShellBuilder
+ extends AbstractContinuumBuilder
+ implements ContinuumBuilder
{
public final static String CONFIGURATION_GOALS = "goals";
public final static String ID = "maven2";
/** @requirement */
+ private ShellCommandHelper shellCommandHelper;
+
+ /** @requirement */
private MavenBuilderHelper builderHelper;
/** @configuration */
@@ -48,31 +55,51 @@ public class MavenShellBuilder
// ContinuumBuilder Implementation
// ----------------------------------------------------------------------
- public ContinuumProject createProjectFromMetadata( URL metadata )
+ public ContinuumBuildResult build( ContinuumProject project )
throws ContinuumException
{
- return builderHelper.createProjectFromMetadata( metadata );
- }
+ File workingDirectory = new File( project.getWorkingDirectory() );
- public void updateProjectFromCheckOut( File workingDirectory, ContinuumProject project )
- throws ContinuumException
- {
- builderHelper.updateProjectFromMetadata( workingDirectory, project );
- }
+ ExecutionResult executionResult;
- // ----------------------------------------------------------------------
- // ShellBuilder Implementation
- // ----------------------------------------------------------------------
+ String[] arguments = getArguments( project );
+
+ try
+ {
+ executionResult = shellCommandHelper.executeShellCommand( workingDirectory,
+ executable,
+ arguments );
+ }
+ catch ( Exception e )
+ {
+ throw new ContinuumException( "Error while executing shell command.", e );
+ }
+
+ boolean success = executionResult.getExitCode() == 0;
- protected boolean prependWorkingDirectoryIfMissing()
+ MavenTwoBuildResult result = new MavenTwoBuildResult();
+
+ result.setSuccess( success );
+
+ result.setStandardOutput( executionResult.getStandardOutput() );
+
+ result.setStandardError( executionResult.getStandardError() );
+
+ result.setExitCode( executionResult.getExitCode() );
+
+ return result;
+ }
+
+ public ContinuumProject createProjectFromMetadata( URL metadata )
+ throws ContinuumException
{
- return false;
+ return builderHelper.createProjectFromMetadata( metadata );
}
- protected String getExecutable( ContinuumProject project )
+ public void updateProjectFromCheckOut( File workingDirectory, ContinuumProject project )
throws ContinuumException
{
- return executable;
+ builderHelper.updateProjectFromMetadata( workingDirectory, project );
}
protected String[] getArguments( ContinuumProject project )
@@ -88,8 +115,6 @@ public class MavenShellBuilder
System.arraycopy( goals, 0, arguments, a.length, goals.length );
- System.err.println( "arguments: " + Arrays.asList( arguments ) );
-
return arguments;
}
}