001 package org.apache.maven.scm.plugin; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import org.apache.maven.plugin.MojoExecutionException; 023 import org.apache.maven.scm.ScmException; 024 import org.apache.maven.scm.command.checkin.CheckInScmResult; 025 import org.apache.maven.scm.repository.ScmRepository; 026 027 import java.io.IOException; 028 029 /** 030 * Commit changes to the configured scm url. 031 * 032 * @author <a href="evenisse@apache.org">Emmanuel Venisse</a> 033 * @version $Id: CheckinMojo.java 685670 2008-08-13 20:25:56Z vsiveton $ 034 * @goal checkin 035 * @aggregator 036 */ 037 public class CheckinMojo 038 extends AbstractScmMojo 039 { 040 /** 041 * Commit log. 042 * 043 * @parameter expression="${message}" 044 */ 045 private String message; 046 047 /** 048 * The configured scm url to use. 049 * 050 * @parameter expression="${connectionType}" default-value="developerConnection" 051 */ 052 private String connectionType; 053 054 /** 055 * The version type (branch/tag/revision) of scmVersion. 056 * 057 * @parameter expression="${scmVersionType}" 058 */ 059 private String scmVersionType; 060 061 /** 062 * The version (revision number/branch name/tag name). 063 * 064 * @parameter expression="${scmVersion}" 065 */ 066 private String scmVersion; 067 068 /** {@inheritDoc} */ 069 public void execute() 070 throws MojoExecutionException 071 { 072 super.execute(); 073 074 setConnectionType( connectionType ); 075 076 try 077 { 078 ScmRepository repository = getScmRepository(); 079 080 CheckInScmResult result = getScmManager().checkIn( repository, getFileSet(), 081 getScmVersion( scmVersionType, scmVersion ), message ); 082 083 checkResult( result ); 084 } 085 catch ( IOException e ) 086 { 087 throw new MojoExecutionException( "Cannot run checkin command : ", e ); 088 } 089 catch ( ScmException e ) 090 { 091 throw new MojoExecutionException( "Cannot run checkin command : ", e ); 092 } 093 } 094 }