Coverage Report - org.apache.maven.plugins.release.BranchReleaseMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
BranchReleaseMojo
0%
0/30
0%
0/4
7
 
 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.commons.lang.StringUtils;
 23  
 import org.apache.maven.plugin.MojoExecutionException;
 24  
 import org.apache.maven.plugin.MojoFailureException;
 25  
 import org.apache.maven.shared.release.ReleaseExecutionException;
 26  
 import org.apache.maven.shared.release.ReleaseFailureException;
 27  
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 28  
 import org.apache.maven.shared.release.config.ReleaseUtils;
 29  
 
 30  
 import java.util.Arrays;
 31  
 
 32  
 /**
 33  
  * Branch a project in SCM, using the same steps as the <tt>release:prepare</tt> goal, creating a branch instead of a tag.
 34  
  * For more info see <a href="http://maven.apache.org/plugins/maven-release-plugin/examples/branch.html">http://maven.apache.org/plugins/maven-release-plugin/examples/branch.html</a>.
 35  
  *
 36  
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
 37  
  * @version $Id$
 38  
  * @aggregator
 39  
  * @goal branch
 40  
  * @since 2.0-beta-6
 41  
  */
 42  0
 public class BranchReleaseMojo
 43  
     extends AbstractReleaseMojo
 44  
 {
 45  
     /**
 46  
      * The branch name to use.
 47  
      *
 48  
      * @parameter expression="${branchName}"
 49  
      * @required
 50  
      * @since 2.0-beta-6
 51  
      */
 52  
     private String branchName;
 53  
 
 54  
     /**
 55  
      * The branch base directory in SVN, you must define it if you don't use the standard svn layout (trunk/tags/branches).
 56  
      * For example, <code>http://svn.apache.org/repos/asf/maven/plugins/branches</code>. The URL is an SVN URL and does not
 57  
      * include the SCM provider and protocol.
 58  
      *
 59  
      * @parameter expression="${branchBase}"
 60  
      * @since 2.0
 61  
      */
 62  
     private String branchBase;
 63  
 
 64  
     /**
 65  
      * Whether to update versions in the branch.
 66  
      *
 67  
      * @parameter expression="${updateBranchVersions}" default-value="false"
 68  
      * @since 2.0-beta-6
 69  
      */
 70  
     private boolean updateBranchVersions;
 71  
 
 72  
     /**
 73  
      * Whether to update versions in the working copy.
 74  
      *
 75  
      * @parameter expression="${updateWorkingCopyVersions}" default-value="true"
 76  
      * @since 2.0-beta-6
 77  
      */
 78  
     private boolean updateWorkingCopyVersions;
 79  
 
 80  
     /**
 81  
      * Whether to suppress a commit of changes to the working copy
 82  
      * before the tag is created.
 83  
      * <br/>
 84  
      * <br/>This requires <code>remoteTagging</code> to be set to false.
 85  
      * <br/>
 86  
      * <br/><code>suppressCommitBeforeBranch</code> is useful when you want
 87  
      * to avoid poms with released versions in all revisions of your
 88  
      * trunk or development branch.
 89  
      *
 90  
      * @parameter expression="${suppressCommitBeforeBranch}" default-value="false"
 91  
      * @since 2.1
 92  
      */
 93  
     private boolean suppressCommitBeforeBranch;
 94  
 
 95  
     /**
 96  
      * Whether to update versions to SNAPSHOT in the branch.
 97  
      *
 98  
      * @parameter expression="${updateVersionsToSnapshot}" default-value="true"
 99  
      * @since 2.0-beta-6
 100  
      */
 101  
     private boolean updateVersionsToSnapshot;
 102  
 
 103  
     /**
 104  
      * Whether to use "edit" mode on the SCM, to lock the file for editing during SCM operations.
 105  
      *
 106  
      * @parameter expression="${useEditMode}" default-value="false"
 107  
      * @since 2.0-beta-6
 108  
      */
 109  
     private boolean useEditMode;
 110  
 
 111  
     /**
 112  
      * Whether to update dependencies version to the next development version.
 113  
      *
 114  
      * @parameter expression="${updateDependencies}" default-value="true"
 115  
      * @since 2.0-beta-6
 116  
      */
 117  
     private boolean updateDependencies;
 118  
 
 119  
     /**
 120  
      * Whether to automatically assign submodules the parent version.  If set to false,
 121  
      * the user will be prompted for the version of each submodules.
 122  
      *
 123  
      * @parameter expression="${autoVersionSubmodules}" default-value="false"
 124  
      * @since 2.0-beta-6
 125  
      */
 126  
     private boolean autoVersionSubmodules;
 127  
 
 128  
     /**
 129  
      * Dry run: don't checkin or tag anything in the scm repository, or modify the checkout.
 130  
      * Running <code>mvn -DdryRun=true release:prepare</code> is useful in order to check that modifications to
 131  
      * poms and scm operations (only listed on the console) are working as expected.
 132  
      * Modified POMs are written alongside the originals without modifying them.
 133  
      *
 134  
      * @parameter expression="${dryRun}" default-value="false"
 135  
      * @since 2.0-beta-6
 136  
      */
 137  
     private boolean dryRun;
 138  
 
 139  
     /**
 140  
      * Whether to add a schema to the POM if it was previously missing on release.
 141  
      *
 142  
      * @parameter expression="${addSchema}" default-value="true"
 143  
      * @since 2.0-beta-6
 144  
      */
 145  
     private boolean addSchema;
 146  
 
 147  
     /**
 148  
      * currently only implemented with svn scm. Enable a workaround to prevent issue
 149  
      * due to svn client > 1.5.0 (http://jira.codehaus.org/browse/SCM-406)
 150  
      *
 151  
      *
 152  
      * @parameter expression="${remoteTagging}" default-value="true"
 153  
      * @since 2.0
 154  
      */
 155  
     private boolean remoteTagging;
 156  
 
 157  
      /**
 158  
      * Additional files that will skipped when checking for
 159  
      * modifications on the working copy.
 160  
      *
 161  
      * Is ignored, when checkModificationExcludes is set.
 162  
      *
 163  
      *
 164  
      * @parameter
 165  
      * @since 2.1
 166  
      */
 167  
     private String[] checkModificationExcludes;
 168  
 
 169  
     /**
 170  
      * Command-line version of checkModificationExcludes
 171  
      *
 172  
      *
 173  
      * @parameter expression="${checkModificationExcludeList}"
 174  
      * @since 2.1
 175  
      */
 176  
     private String checkModificationExcludeList;
 177  
 
 178  
     /**
 179  
      * Default version to use when preparing a release or a branch.
 180  
      *
 181  
      * @parameter expression="${releaseVersion}"
 182  
      * @since 2.0
 183  
      */
 184  
     private String releaseVersion;
 185  
 
 186  
     /**
 187  
      * Default version to use for new local working copy.
 188  
      *
 189  
      * @parameter expression="${developmentVersion}"
 190  
      * @since 2.0
 191  
      */
 192  
     private String developmentVersion;
 193  
 
 194  
     /**
 195  
      * {@inheritDoc}
 196  
      */
 197  
     public void execute()
 198  
         throws MojoExecutionException, MojoFailureException
 199  
     {
 200  0
         super.execute();
 201  
 
 202  0
         ReleaseDescriptor config = createReleaseDescriptor();
 203  0
         config.setAddSchema( addSchema );
 204  0
         config.setScmUseEditMode( useEditMode );
 205  0
         config.setUpdateDependencies( updateDependencies );
 206  0
         config.setAutoVersionSubmodules( autoVersionSubmodules );
 207  0
         config.setScmReleaseLabel( branchName );
 208  0
         config.setScmBranchBase( branchBase );
 209  0
         config.setBranchCreation( true );
 210  0
         config.setUpdateBranchVersions( updateBranchVersions );
 211  0
         config.setUpdateWorkingCopyVersions( updateWorkingCopyVersions );
 212  0
         config.setUpdateVersionsToSnapshot( updateVersionsToSnapshot );
 213  0
         config.setRemoteTagging( remoteTagging );
 214  0
         config.setDefaultReleaseVersion( releaseVersion );
 215  0
         config.setDefaultDevelopmentVersion( developmentVersion );
 216  0
         config.setSuppressCommitBeforeTagOrBranch( suppressCommitBeforeBranch );
 217  
 
 218  
         // Create a config containing values from the session properties (ie command line properties with cli).
 219  0
         ReleaseDescriptor sysPropertiesConfig
 220  
                 = ReleaseUtils.copyPropertiesToReleaseDescriptor( session.getExecutionProperties() );
 221  0
         mergeCommandLineConfig( config, sysPropertiesConfig );
 222  
 
 223  0
         if ( checkModificationExcludeList != null )
 224  
         {
 225  0
             checkModificationExcludes = checkModificationExcludeList.replaceAll( "\\s", "" ).split( "," );
 226  
         }
 227  
 
 228  0
         if ( checkModificationExcludes != null )
 229  
         {
 230  0
             config.setCheckModificationExcludes( Arrays.asList( checkModificationExcludes ) );
 231  
         }
 232  
 
 233  
         try
 234  
         {
 235  0
             releaseManager.branch( config, getReleaseEnvironment(), reactorProjects, dryRun );
 236  
         }
 237  0
         catch ( ReleaseExecutionException e )
 238  
         {
 239  0
             throw new MojoExecutionException( e.getMessage(), e );
 240  
         }
 241  0
         catch ( ReleaseFailureException e )
 242  
         {
 243  0
             throw new MojoFailureException( e.getMessage(), e );
 244  0
         }
 245  0
     }
 246  
 }