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