View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.release;
20  
21  import javax.inject.Inject;
22  
23  import org.apache.maven.plugins.annotations.Parameter;
24  import org.apache.maven.scm.manager.ScmManager;
25  import org.apache.maven.shared.release.ReleaseManager;
26  import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
27  
28  /**
29   * Abstract Mojo containing SCM parameters for read/write operations.
30   *
31   * @author Robert Scholte
32   */
33  // Extra layer since 2.4. Don't use @since doclet, these would be inherited by the subclasses
34  public abstract class AbstractScmReadWriteReleaseMojo extends AbstractScmReadReleaseMojo {
35      /**
36       * The SCM tag to use.
37       */
38      @Parameter(alias = "releaseLabel", property = "tag")
39      private String tag;
40  
41      /**
42       * Format to use when generating the tag name if none is specified. Property interpolation is performed on the
43       * tag, but in order to ensure that the interpolation occurs during release, you must use <code>@{...}</code>
44       * to reference the properties rather than <code>${...}</code>. The following properties are available:
45       * <ul>
46       *     <li><code>groupId</code> or <code>project.groupId</code> - The groupId of the root project.
47       *     <li><code>artifactId</code> or <code>project.artifactId</code> - The artifactId of the root project.
48       *     <li><code>version</code> or <code>project.version</code> - The release version of the root project.
49       * </ul>
50       *
51       * @since 2.2.0
52       */
53      @Parameter(defaultValue = "@{project.artifactId}-@{project.version}", property = "tagNameFormat")
54      private String tagNameFormat;
55  
56      /**
57       * The tag base directory in SVN, you must define it if you don't use the standard svn layout (trunk/tags/branches).
58       * For example, <code>http://svn.apache.org/repos/asf/maven/plugins/tags</code>. The URL is an SVN URL and does not
59       * include the SCM provider and protocol.
60       */
61      @Parameter(property = "tagBase")
62      private String tagBase;
63  
64      /**
65       * The message prefix to use for all SCM changes.
66       *
67       * @since 2.0-beta-5
68       */
69      @Parameter(defaultValue = "[maven-release-plugin] ", property = "scmCommentPrefix")
70      private String scmCommentPrefix;
71  
72      /**
73       * Whether to push changes to the upstream repository or not.
74       * Only applicable to distributed version control like Git.
75       * Is set to <code>true</code> by default to preserve backward compatibility.
76       *
77       * @since 2.1
78       */
79      @Parameter(defaultValue = "true", property = "pushChanges")
80      private boolean pushChanges = true;
81  
82      /**
83       * A workItem for SCMs like RTC, TFS etc, that may require additional
84       * information to perform a pushChange operation.
85       *
86       * @since 3.0.0-M5
87       */
88      @Parameter(property = "workItem")
89      private String workItem;
90  
91      @Inject
92      protected AbstractScmReadWriteReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) {
93          super(releaseManager, scmManager);
94      }
95  
96      @Override
97      protected ReleaseDescriptorBuilder createReleaseDescriptor() {
98          ReleaseDescriptorBuilder descriptor = super.createReleaseDescriptor();
99  
100         // extend the descriptor with SCM parameter relevant for write operations
101         descriptor.setScmReleaseLabel(tag);
102         descriptor.setScmTagNameFormat(tagNameFormat);
103         descriptor.setScmTagBase(tagBase);
104         descriptor.setScmCommentPrefix(scmCommentPrefix);
105 
106         descriptor.setPushChanges(pushChanges);
107         descriptor.setWorkItem(workItem);
108 
109         return descriptor;
110     }
111 }