1 package org.apache.maven.shared.release.exec;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.shared.release.ReleaseResult;
23 import org.apache.maven.shared.release.env.DefaultReleaseEnvironment;
24 import org.apache.maven.shared.release.env.ReleaseEnvironment;
25 import org.codehaus.plexus.logging.LogEnabled;
26 import org.codehaus.plexus.logging.Logger;
27 import org.codehaus.plexus.util.StringUtils;
28
29 import java.io.File;
30 import java.util.ArrayList;
31 import java.util.List;
32
33 public abstract class AbstractMavenExecutor
34 implements MavenExecutor, LogEnabled
35 {
36
37 private Logger logger;
38
39 protected AbstractMavenExecutor()
40 {
41 }
42
43
44 public void executeGoals( File workingDirectory, String goals, boolean interactive, String additionalArguments,
45 String pomFileName, ReleaseResult result )
46 throws MavenExecutorException
47 {
48 executeGoals( workingDirectory, goals, new DefaultReleaseEnvironment(), interactive, additionalArguments, pomFileName, result );
49 }
50
51
52 public void executeGoals( File workingDirectory, String goals, boolean interactive, String additionalArguments,
53 ReleaseResult result )
54 throws MavenExecutorException
55 {
56 executeGoals( workingDirectory, goals, new DefaultReleaseEnvironment(), interactive, additionalArguments, result );
57 }
58
59
60 public void executeGoals( File workingDirectory, String goals, ReleaseEnvironment releaseEnvironment,
61 boolean interactive, String arguments, ReleaseResult result )
62 throws MavenExecutorException
63 {
64 executeGoals( workingDirectory, goals, releaseEnvironment, interactive, arguments, null, result );
65 }
66
67
68 public void executeGoals( File workingDirectory, String goals, ReleaseEnvironment releaseEnvironment,
69 boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result )
70 throws MavenExecutorException
71 {
72 List<String> goalsList = new ArrayList<String>();
73 if ( goals != null )
74 {
75
76
77
78 String[] tokens = StringUtils.split( goals, ", \n\r\t" );
79
80 for ( int i = 0; i < tokens.length; ++i )
81 {
82 goalsList.add( tokens[i] );
83 }
84 }
85 executeGoals( workingDirectory, goalsList, releaseEnvironment, interactive, additionalArguments, pomFileName, result );
86 }
87
88 protected abstract void executeGoals( File workingDirectory, List<String> goals, ReleaseEnvironment releaseEnvironment,
89 boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result )
90 throws MavenExecutorException;
91
92
93 protected final Logger getLogger()
94 {
95 return logger;
96 }
97
98
99 public void enableLogging( Logger logger )
100 {
101 this.logger = logger;
102 }
103 }