Coverage Report - org.apache.maven.scm.plugin.UpdateSubprojectsMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdateSubprojectsMojo
0%
0/15
0%
0/4
7
 
 1  
 package org.apache.maven.scm.plugin;
 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.project.MavenProject;
 24  
 import org.apache.maven.scm.ScmException;
 25  
 import org.apache.maven.scm.command.update.UpdateScmResult;
 26  
 import org.apache.maven.scm.command.update.UpdateScmResultWithRevision;
 27  
 import org.apache.maven.scm.repository.ScmRepository;
 28  
 
 29  
 import java.io.IOException;
 30  
 
 31  
 /**
 32  
  * Updates all projects in a multi project build. This is useful for users who have adopted the flat project structure
 33  
  * where the aggregator project is a sibling of the sub projects rather than sitting in the parent directory.
 34  
  *
 35  
  * @goal update-subprojects
 36  
  * @version $Id: UpdateSubprojectsMojo.java 685542 2008-08-13 13:28:43Z vsiveton $
 37  
  */
 38  0
 public class UpdateSubprojectsMojo
 39  
     extends AbstractScmMojo
 40  
 {
 41  
     /**
 42  
      * The version type (branch/tag/revision) of scmVersion.
 43  
      *
 44  
      * @parameter expression="${scmVersionType}"
 45  
      */
 46  
     private String scmVersionType;
 47  
 
 48  
     /**
 49  
      * The version (revision number/branch name/tag name).
 50  
      *
 51  
      * @parameter expression="${scmVersion}"
 52  
      */
 53  
     private String scmVersion;
 54  
 
 55  
     /**
 56  
      * The project property where to store the revision name.
 57  
      *
 58  
      * @parameter expression="${revisionKey}" default-value="scm.revision"
 59  
      */
 60  
     private String revisionKey;
 61  
 
 62  
     /**
 63  
      * The maven project.
 64  
      *
 65  
      * @parameter expression="${project}"
 66  
      * @required
 67  
      * @readonly
 68  
      */
 69  
     private MavenProject project;
 70  
 
 71  
     /** {@inheritDoc} */
 72  
     public void execute()
 73  
         throws MojoExecutionException
 74  
     {
 75  0
         super.execute();
 76  
 
 77  
         try
 78  
         {
 79  0
             ScmRepository repository = getScmRepository();
 80  
 
 81  0
             UpdateScmResult result =
 82  
                 getScmManager().update( repository, getFileSet(), getScmVersion( scmVersionType, scmVersion ) );
 83  
 
 84  0
             checkResult( result );
 85  
 
 86  0
             if ( result instanceof UpdateScmResultWithRevision )
 87  
             {
 88  0
                 getLog().info( "Storing revision in '" + revisionKey + "' project property." );
 89  
 
 90  0
                 if ( project.getProperties() != null ) // Remove the test when we'll use plugin-test-harness 1.0-alpha-2
 91  
                 {
 92  0
                     project.getProperties().put( revisionKey, ( (UpdateScmResultWithRevision) result ).getRevision() );
 93  
                 }
 94  
             }
 95  
         }
 96  0
         catch ( IOException e )
 97  
         {
 98  0
             throw new MojoExecutionException( "Cannot run update command : ", e );
 99  
         }
 100  0
         catch ( ScmException e )
 101  
         {
 102  0
             throw new MojoExecutionException( "Cannot run update command : ", e );
 103  0
         }
 104  0
     }
 105  
 }