Coverage Report - org.apache.maven.plugins.release.UpdateVersionsMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdateVersionsMojo
0%
0/18
N/A
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 java.util.HashMap;
 23  
 import java.util.Map;
 24  
 
 25  
 import org.apache.maven.artifact.ArtifactUtils;
 26  
 import org.apache.maven.execution.MavenSession;
 27  
 import org.apache.maven.plugin.MojoExecutionException;
 28  
 import org.apache.maven.plugin.MojoFailureException;
 29  
 import org.apache.maven.shared.release.ReleaseExecutionException;
 30  
 import org.apache.maven.shared.release.ReleaseFailureException;
 31  
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 32  
 import org.apache.maven.shared.release.config.ReleaseUtils;
 33  
 
 34  
 /**
 35  
  * Update the POM versions for a project. This performs the normal version updates of the <tt>release:prepare</tt>
 36  
  * goal without making other modifications to the SCM such as tagging.
 37  
  * For more info see <a href="http://maven.apache.org/plugins/maven-release-plugin/examples/update-versions.html">http://maven.apache.org/plugins/maven-release-plugin/examples/update-versions.html</a>.
 38  
  *
 39  
  * @author Paul Gier
 40  
  * @version $Id$
 41  
  * @aggregator
 42  
  * @goal update-versions
 43  
  * @since 2.0
 44  
  */
 45  0
 public class UpdateVersionsMojo
 46  
     extends AbstractReleaseMojo
 47  
 {
 48  
 
 49  
     /**
 50  
      * Whether to automatically assign submodules the parent version. If set to false, the user will be prompted for the
 51  
      * version of each submodules.
 52  
      *
 53  
      * @parameter expression="${autoVersionSubmodules}" default-value="false"
 54  
      * @since 2.0
 55  
      */
 56  
     private boolean autoVersionSubmodules;
 57  
 
 58  
     /**
 59  
      * Whether to add a schema to the POM if it was previously missing on release.
 60  
      *
 61  
      * @parameter expression="${addSchema}" default-value="true"
 62  
      * @since 2.0
 63  
      */
 64  
     private boolean addSchema;
 65  
 
 66  
     /**
 67  
      * Default version to use for new local working copy.
 68  
      *
 69  
      * @parameter expression="${developmentVersion}"
 70  
      * @since 2.0
 71  
      */
 72  
     private String developmentVersion;
 73  
 
 74  
     /**
 75  
      * @parameter expression="${session}"
 76  
      * @readonly
 77  
      * @required
 78  
      * @since 2.0
 79  
      */
 80  
     protected MavenSession session;
 81  
 
 82  
     /**
 83  
      * {@inheritDoc}
 84  
      */
 85  
     public void execute()
 86  
         throws MojoExecutionException, MojoFailureException
 87  
     {
 88  0
         super.execute();
 89  
 
 90  0
         ReleaseDescriptor config = createReleaseDescriptor();
 91  0
         config.setAddSchema( addSchema );
 92  0
         config.setAutoVersionSubmodules( autoVersionSubmodules );
 93  0
         config.setDefaultDevelopmentVersion( developmentVersion );
 94  
 
 95  0
         Map originalScmInfo = new HashMap();
 96  0
         originalScmInfo.put( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ), project.getScm() );
 97  0
         config.setOriginalScmInfo( originalScmInfo );
 98  
 
 99  
         // Create a config containing values from the session properties (ie command line properties with cli).
 100  0
         ReleaseDescriptor sysPropertiesConfig
 101  
                 = ReleaseUtils.copyPropertiesToReleaseDescriptor( session.getExecutionProperties() );
 102  0
         mergeCommandLineConfig( config, sysPropertiesConfig );
 103  
 
 104  
         try
 105  
         {
 106  0
             releaseManager.updateVersions( config, getReleaseEnvironment(), reactorProjects );
 107  
         }
 108  0
         catch ( ReleaseExecutionException e )
 109  
         {
 110  0
             throw new MojoExecutionException( e.getMessage(), e );
 111  
         }
 112  0
         catch ( ReleaseFailureException e )
 113  
         {
 114  0
             throw new MojoFailureException( e.getMessage(), e );
 115  0
         }
 116  0
     }
 117  
 }