View Javadoc

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.plugins.annotations.Mojo;
24  import org.apache.maven.plugins.annotations.Parameter;
25  import org.apache.maven.scm.ScmException;
26  import org.apache.maven.scm.command.checkin.CheckInScmResult;
27  import org.apache.maven.scm.repository.ScmRepository;
28  
29  import java.io.IOException;
30  
31  /**
32   * Commit changes to the configured scm url.
33   *
34   * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
35   */
36  @Mojo( name = "checkin", aggregator = true )
37  public class CheckinMojo
38      extends AbstractScmMojo
39  {
40      /**
41       * Commit log.
42       */
43      @Parameter( property = "message" )
44      private String message;
45  
46      /**
47       * The configured scm url to use.
48       */
49      @Parameter( property = "connectionType", defaultValue = "developerConnection" )
50      private String connectionType;
51  
52      /**
53       * The version type (branch/tag/revision) of scmVersion.
54       */
55      @Parameter( property = "scmVersionType" )
56      private String scmVersionType;
57  
58      /**
59       * The version (revision number/branch name/tag name).
60       */
61      @Parameter( property = "scmVersion" )
62      private String scmVersion;
63  
64      /** {@inheritDoc} */
65      public void execute()
66          throws MojoExecutionException
67      {
68          super.execute();
69  
70          setConnectionType( connectionType );
71  
72          try
73          {
74              ScmRepository repository = getScmRepository();
75  
76              CheckInScmResult result = getScmManager().checkIn( repository, getFileSet(),
77                                                                 getScmVersion( scmVersionType, scmVersion ), message );
78  
79              checkResult( result );
80          }
81          catch ( IOException e )
82          {
83              throw new MojoExecutionException( "Cannot run checkin command : ", e );
84          }
85          catch ( ScmException e )
86          {
87              throw new MojoExecutionException( "Cannot run checkin command : ", e );
88          }
89      }
90  }