Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BranchReleaseMojo |
|
| 5.0;5 |
1 | package org.apache.maven.plugins.release; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.maven.plugin.MojoExecutionException; | |
23 | import org.apache.maven.plugin.MojoFailureException; | |
24 | import org.apache.maven.shared.release.ReleaseExecutionException; | |
25 | import org.apache.maven.shared.release.ReleaseFailureException; | |
26 | import org.apache.maven.shared.release.config.ReleaseDescriptor; | |
27 | ||
28 | /** | |
29 | * Branch a project in SCM. | |
30 | * For more info see <a href="/plugins/maven-release-plugin/examples/branch.html">this example</a>. | |
31 | * | |
32 | * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> | |
33 | * @version $Id$ | |
34 | * @aggregator | |
35 | * @goal branch | |
36 | * @since 2.0-beta-6 | |
37 | */ | |
38 | 0 | public class BranchReleaseMojo |
39 | extends AbstractReleaseMojo | |
40 | { | |
41 | /** | |
42 | * The branch name to use. | |
43 | * | |
44 | * @parameter expression="${branchName}" | |
45 | * @required | |
46 | * @since 2.0-beta-6 | |
47 | */ | |
48 | private String branchName; | |
49 | ||
50 | /** | |
51 | * The branch base directory in SVN, you must define it if you don't use the standard svn layout (trunk/tags/branches). | |
52 | * For example, <code>http://svn.apache.org/repos/asf/maven/plugins/branches</code>. The URL is an SVN URL and does not | |
53 | * include the SCM provider and protocol. | |
54 | * | |
55 | * @parameter expression="${branchBase}" | |
56 | * @since 2.0 | |
57 | */ | |
58 | private String branchBase; | |
59 | ||
60 | /** | |
61 | * Whether to update versions in the branch. | |
62 | * | |
63 | * @parameter expression="${updateBranchVersions}" default-value="false" | |
64 | * @since 2.0-beta-6 | |
65 | */ | |
66 | private boolean updateBranchVersions; | |
67 | ||
68 | /** | |
69 | * Whether to update versions in the working copy. | |
70 | * | |
71 | * @parameter expression="${updateWorkingCopyVersions}" default-value="true" | |
72 | * @since 2.0-beta-6 | |
73 | */ | |
74 | private boolean updateWorkingCopyVersions; | |
75 | ||
76 | /** | |
77 | * Whether to update versions to SNAPSHOT in the branch. | |
78 | * | |
79 | * @parameter expression="${updateVersionsToSnapshot}" default-value="true" | |
80 | * @since 2.0-beta-6 | |
81 | */ | |
82 | private boolean updateVersionsToSnapshot; | |
83 | ||
84 | /** | |
85 | * Whether to use "edit" mode on the SCM, to lock the file for editing during SCM operations. | |
86 | * | |
87 | * @parameter expression="${useEditMode}" default-value="false" | |
88 | * @since 2.0-beta-6 | |
89 | */ | |
90 | private boolean useEditMode; | |
91 | ||
92 | /** | |
93 | * Whether to update dependencies version to the next development version. | |
94 | * | |
95 | * @parameter expression="${updateDependencies}" default-value="true" | |
96 | * @since 2.0-beta-6 | |
97 | */ | |
98 | private boolean updateDependencies; | |
99 | ||
100 | /** | |
101 | * Whether to automatically assign submodules the parent version. If set to false, | |
102 | * the user will be prompted for the version of each submodules. | |
103 | * | |
104 | * @parameter expression="${autoVersionSubmodules}" default-value="false" | |
105 | * @since 2.0-beta-6 | |
106 | */ | |
107 | private boolean autoVersionSubmodules; | |
108 | ||
109 | /** | |
110 | * Dry run: don't checkin or tag anything in the scm repository, or modify the checkout. | |
111 | * Running <code>mvn -DdryRun=true release:prepare</code> is useful in order to check that modifications to | |
112 | * poms and scm operations (only listed on the console) are working as expected. | |
113 | * Modified POMs are written alongside the originals without modifying them. | |
114 | * | |
115 | * @parameter expression="${dryRun}" default-value="false" | |
116 | * @since 2.0-beta-6 | |
117 | */ | |
118 | private boolean dryRun; | |
119 | ||
120 | /** | |
121 | * Whether to add a schema to the POM if it was previously missing on release. | |
122 | * | |
123 | * @parameter expression="${addSchema}" default-value="true" | |
124 | * @since 2.0-beta-6 | |
125 | */ | |
126 | private boolean addSchema; | |
127 | ||
128 | /** | |
129 | * currently only implemented with svn scm. Enable a workaround to prevent issue | |
130 | * due to svn client > 1.5.0 (http://jira.codehaus.org/browse/SCM-406) | |
131 | * | |
132 | * | |
133 | * @parameter expression="${remoteTagging}" default-value="true" | |
134 | * @since 2.0 | |
135 | */ | |
136 | private boolean remoteTagging; | |
137 | ||
138 | /** | |
139 | * Default version to use when preparing a release or a branch. | |
140 | * | |
141 | * @parameter expression="${releaseVersion}" | |
142 | * @since 2.0 | |
143 | */ | |
144 | private String releaseVersion; | |
145 | ||
146 | /** | |
147 | * Default version to use for new local working copy. | |
148 | * | |
149 | * @parameter expression="${developmentVersion}" | |
150 | * @since 2.0 | |
151 | */ | |
152 | private String developmentVersion; | |
153 | ||
154 | /** | |
155 | * {@inheritDoc} | |
156 | */ | |
157 | public void execute() | |
158 | throws MojoExecutionException, MojoFailureException | |
159 | { | |
160 | 0 | super.execute(); |
161 | ||
162 | 0 | ReleaseDescriptor config = createReleaseDescriptor(); |
163 | 0 | config.setAddSchema( addSchema ); |
164 | 0 | config.setScmUseEditMode( useEditMode ); |
165 | 0 | config.setUpdateDependencies( updateDependencies ); |
166 | 0 | config.setAutoVersionSubmodules( autoVersionSubmodules ); |
167 | 0 | config.setScmReleaseLabel( branchName ); |
168 | 0 | config.setScmBranchBase( branchBase ); |
169 | 0 | config.setBranchCreation( true ); |
170 | 0 | config.setUpdateBranchVersions( updateBranchVersions ); |
171 | 0 | config.setUpdateWorkingCopyVersions( updateWorkingCopyVersions ); |
172 | 0 | config.setUpdateVersionsToSnapshot( updateVersionsToSnapshot ); |
173 | 0 | config.setRemoteTagging( remoteTagging ); |
174 | 0 | config.setDefaultReleaseVersion( releaseVersion ); |
175 | 0 | config.setDefaultDevelopmentVersion( developmentVersion ); |
176 | try | |
177 | { | |
178 | 0 | releaseManager.branch( config, getReleaseEnvironment(), reactorProjects, dryRun ); |
179 | } | |
180 | 0 | catch ( ReleaseExecutionException e ) |
181 | { | |
182 | 0 | throw new MojoExecutionException( e.getMessage(), e ); |
183 | } | |
184 | 0 | catch ( ReleaseFailureException e ) |
185 | { | |
186 | 0 | throw new MojoFailureException( e.getMessage(), e ); |
187 | 0 | } |
188 | 0 | } |
189 | } |