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.util.Arrays;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.Parameter;
28 import org.apache.maven.shared.release.ReleaseExecutionException;
29 import org.apache.maven.shared.release.ReleaseFailureException;
30 import org.apache.maven.shared.release.config.ReleaseDescriptor;
31 import org.apache.maven.shared.release.config.ReleaseUtils;
32
33
34
35
36
37
38
39
40
41 @Mojo( name = "branch", aggregator = true )
42 public class BranchReleaseMojo
43 extends AbstractScmReleaseMojo
44 {
45
46
47
48
49
50
51 @Parameter( property = "branchName", required = true )
52 private String branchName;
53
54
55
56
57
58
59
60
61 @Parameter( property = "branchBase" )
62 private String branchBase;
63
64
65
66
67
68
69 @Parameter( defaultValue = "false", property = "updateBranchVersions" )
70 private boolean updateBranchVersions;
71
72
73
74
75
76
77 @Parameter( defaultValue = "true", property = "updateWorkingCopyVersions" )
78 private boolean updateWorkingCopyVersions;
79
80
81
82
83
84
85
86
87
88
89
90
91
92 @Parameter( defaultValue = "false", property = "suppressCommitBeforeBranch" )
93 private boolean suppressCommitBeforeBranch;
94
95
96
97
98
99
100 @Parameter( defaultValue = "true", property = "updateVersionsToSnapshot" )
101 private boolean updateVersionsToSnapshot;
102
103
104
105
106
107
108 @Parameter( defaultValue = "false", property = "useEditMode" )
109 private boolean useEditMode;
110
111
112
113
114
115
116 @Parameter( defaultValue = "true", property = "updateDependencies" )
117 private boolean updateDependencies;
118
119
120
121
122
123
124
125 @Parameter( defaultValue = "false", property = "autoVersionSubmodules" )
126 private boolean autoVersionSubmodules;
127
128
129
130
131
132
133
134
135
136 @Parameter( defaultValue = "false", property = "dryRun" )
137 private boolean dryRun;
138
139
140
141
142
143
144 @Parameter( defaultValue = "true", property = "addSchema" )
145 private boolean addSchema;
146
147
148
149
150
151
152
153 @Parameter( defaultValue = "true", property = "remoteTagging" )
154 private boolean remoteTagging;
155
156
157
158
159
160
161
162
163
164 @Parameter
165 private String[] checkModificationExcludes;
166
167
168
169
170
171
172 @Parameter( property = "checkModificationExcludeList" )
173 private String checkModificationExcludeList;
174
175
176
177
178
179
180
181 @Parameter( property = "releaseVersion" )
182 private String releaseVersion;
183
184
185
186
187
188
189
190 @Parameter( property = "developmentVersion" )
191 private String developmentVersion;
192
193
194
195
196 public void execute()
197 throws MojoExecutionException, MojoFailureException
198 {
199 super.execute();
200
201 ReleaseDescriptor config = createReleaseDescriptor();
202 config.setAddSchema( addSchema );
203 config.setScmUseEditMode( useEditMode );
204 config.setUpdateDependencies( updateDependencies );
205 config.setAutoVersionSubmodules( autoVersionSubmodules );
206 config.setScmReleaseLabel( branchName );
207 config.setScmBranchBase( branchBase );
208 config.setBranchCreation( true );
209 config.setUpdateBranchVersions( updateBranchVersions );
210 config.setUpdateWorkingCopyVersions( updateWorkingCopyVersions );
211 config.setUpdateVersionsToSnapshot( updateVersionsToSnapshot );
212 config.setRemoteTagging( remoteTagging );
213 config.setDefaultReleaseVersion( releaseVersion );
214 config.setDefaultDevelopmentVersion( developmentVersion );
215 config.setSuppressCommitBeforeTagOrBranch( suppressCommitBeforeBranch );
216
217
218 ReleaseDescriptor sysPropertiesConfig
219 = ReleaseUtils.copyPropertiesToReleaseDescriptor( session.getExecutionProperties() );
220 mergeCommandLineConfig( config, sysPropertiesConfig );
221
222 if ( checkModificationExcludeList != null )
223 {
224 checkModificationExcludes = checkModificationExcludeList.replaceAll( "\\s", "" ).split( "," );
225 }
226
227 if ( checkModificationExcludes != null )
228 {
229 config.setCheckModificationExcludes( Arrays.asList( checkModificationExcludes ) );
230 }
231
232 try
233 {
234 releaseManager.branch( config, getReleaseEnvironment(), getReactorProjects(), dryRun );
235 }
236 catch ( ReleaseExecutionException e )
237 {
238 throw new MojoExecutionException( e.getMessage(), e );
239 }
240 catch ( ReleaseFailureException e )
241 {
242 throw new MojoFailureException( e.getMessage(), e );
243 }
244 }
245 }