1 package org.apache.maven.plugins.release;
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
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.shared.release.ReleaseExecutionException;
27 import org.apache.maven.shared.release.ReleaseFailureException;
28 import org.apache.maven.shared.release.config.ReleaseDescriptor;
29 import org.codehaus.plexus.util.StringUtils;
30
31
32
33
34
35
36
37
38
39
40
41 public class StageReleaseMojo
42 extends AbstractReleaseMojo
43 {
44
45
46
47
48
49
50
51 private String goals;
52
53
54
55
56
57
58
59 private String releaseProfiles;
60
61
62
63
64
65
66
67
68 private File workingDirectory;
69
70
71
72
73
74
75
76
77 private String connectionUrl;
78
79
80
81
82
83
84
85 private boolean useReleaseProfile;
86
87
88
89
90
91
92
93
94 private String stagingRepository;
95
96
97
98
99 protected String getAdditionalProfiles()
100 {
101 return releaseProfiles;
102 }
103
104
105
106
107 public void execute()
108 throws MojoExecutionException, MojoFailureException
109 {
110 super.execute();
111
112
113
114 if ( goals != null )
115 {
116 goals = StringUtils.join( StringUtils.split( goals ), " " );
117 }
118
119 try
120 {
121 addArgument( "-DaltDeploymentRepository=\"" + stagingRepository + "\"" );
122
123
124 ReleaseDescriptor releaseDescriptor = createReleaseDescriptor();
125 if ( connectionUrl != null )
126 {
127 releaseDescriptor.setScmSourceUrl( connectionUrl );
128 }
129
130 releaseDescriptor.setCheckoutDirectory( workingDirectory.getAbsolutePath() );
131 releaseDescriptor.setUseReleaseProfile( useReleaseProfile );
132
133 if ( goals == null )
134 {
135
136 goals = "deploy";
137 if ( project.getDistributionManagement() != null
138 && project.getDistributionManagement().getSite() != null )
139 {
140 goals += " site:stage-deploy";
141 }
142 }
143
144 goals = StringUtils.replace( goals, "site-deploy", "site:stage-deploy" );
145 goals = StringUtils.replace( goals, "site:deploy", "site:stage-deploy" );
146
147 releaseDescriptor.setPerformGoals( goals );
148
149 releaseManager.perform( releaseDescriptor, getReleaseEnvironment(), getReactorProjects(), false );
150 }
151 catch ( ReleaseExecutionException e )
152 {
153 throw new MojoExecutionException( e.getMessage(), e );
154 }
155 catch ( ReleaseFailureException e )
156 {
157 throw new MojoFailureException( e.getMessage(), e );
158 }
159 }
160 }