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