001package 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 022import org.apache.maven.plugin.MojoExecutionException; 023import org.apache.maven.plugins.annotations.Mojo; 024import org.apache.maven.plugins.annotations.Parameter; 025import org.apache.maven.scm.ScmException; 026import org.apache.maven.scm.command.checkin.CheckInScmResult; 027import org.apache.maven.scm.repository.ScmRepository; 028 029import java.io.IOException; 030 031/** 032 * Commit changes to the configured scm url. 033 * 034 * @author <a href="evenisse@apache.org">Emmanuel Venisse</a> 035 */ 036@Mojo( name = "checkin", aggregator = true ) 037public class CheckinMojo 038 extends AbstractScmMojo 039{ 040 /** 041 * Commit log. 042 */ 043 @Parameter( property = "message" ) 044 private String message; 045 046 /** 047 * The configured scm url to use. 048 */ 049 @Parameter( property = "connectionType", defaultValue = "developerConnection" ) 050 private String connectionType; 051 052 /** 053 * The version type (branch/tag/revision) of scmVersion. 054 */ 055 @Parameter( property = "scmVersionType" ) 056 private String scmVersionType; 057 058 /** 059 * The version (revision number/branch name/tag name). 060 */ 061 @Parameter( property = "scmVersion" ) 062 private String scmVersion; 063 064 /** {@inheritDoc} */ 065 public void execute() 066 throws MojoExecutionException 067 { 068 super.execute(); 069 070 setConnectionType( connectionType ); 071 072 try 073 { 074 ScmRepository repository = getScmRepository(); 075 076 CheckInScmResult result = getScmManager().checkIn( repository, getFileSet(), 077 getScmVersion( scmVersionType, scmVersion ), message ); 078 079 checkResult( result ); 080 } 081 catch ( IOException e ) 082 { 083 throw new MojoExecutionException( "Cannot run checkin command : ", e ); 084 } 085 catch ( ScmException e ) 086 { 087 throw new MojoExecutionException( "Cannot run checkin command : ", e ); 088 } 089 } 090}