1 package org.apache.continuum.release.phase;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Map;
24
25 import org.apache.continuum.release.config.ContinuumReleaseDescriptor;
26 import org.apache.continuum.utils.shell.ShellCommandHelper;
27 import org.apache.maven.continuum.installation.InstallationService;
28 import org.apache.maven.shared.release.ReleaseExecutionException;
29 import org.apache.maven.shared.release.ReleaseResult;
30 import org.apache.maven.shared.release.config.ReleaseDescriptor;
31 import org.apache.maven.shared.release.phase.AbstractRunGoalsPhase;
32 import org.codehaus.plexus.util.StringUtils;
33
34
35
36
37 public abstract class AbstractContinuumRunGoalsPhase
38 extends AbstractRunGoalsPhase
39 {
40
41
42
43 private ShellCommandHelper shellCommandHelper;
44
45
46
47
48 private InstallationService installationService;
49
50 public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, File workingDirectory,
51 String additionalArguments )
52 throws ReleaseExecutionException
53 {
54 ReleaseResult result = new ReleaseResult();
55
56 try
57 {
58 String goals = getGoals( releaseDescriptor );
59 if ( !StringUtils.isEmpty( goals ) )
60 {
61 Map<String, String> environments = null;
62
63 String executable = null;
64
65 if ( releaseDescriptor instanceof ContinuumReleaseDescriptor )
66 {
67 environments = ( (ContinuumReleaseDescriptor) releaseDescriptor ).getEnvironments();
68
69 executable = ( (ContinuumReleaseDescriptor) releaseDescriptor).getExecutable();
70 }
71
72 shellCommandHelper.executeGoals( determineWorkingDirectory( workingDirectory,
73 releaseDescriptor.getScmRelativePathProjectDirectory() ),
74 executable, goals, releaseDescriptor.isInteractive(), additionalArguments, result,
75 environments );
76 }
77 }
78 catch ( Exception e )
79 {
80 throw new ReleaseExecutionException( result.getOutput(), e );
81 }
82
83 result.setResultCode( ReleaseResult.SUCCESS );
84
85 return result;
86 }
87 }