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 java.io.IOException; 023import org.apache.maven.plugin.MojoExecutionException; 024import org.apache.maven.plugins.annotations.Mojo; 025import org.apache.maven.plugins.annotations.Parameter; 026import org.apache.maven.scm.CommandParameter; 027import org.apache.maven.scm.CommandParameters; 028import org.apache.maven.scm.ScmException; 029import org.apache.maven.scm.command.untag.UntagScmResult; 030import org.apache.maven.scm.provider.ScmProvider; 031import org.apache.maven.scm.repository.ScmRepository; 032 033/** 034 * Untag the project. 035 */ 036@Mojo( name = "untag", aggregator = true ) 037public class UntagMojo 038 extends AbstractScmMojo 039{ 040 /** 041 * The tag name. 042 */ 043 @Parameter( property = "tag", required = true ) 044 private String tag; 045 046 /** 047 * The commit message. 048 */ 049 @Parameter( property = "message", required = false ) 050 private String message; 051 052 /** {@inheritDoc} */ 053 public void execute() 054 throws MojoExecutionException 055 { 056 super.execute(); 057 058 try 059 { 060 ScmRepository repository = getScmRepository(); 061 ScmProvider provider = getScmManager().getProviderByRepository( repository ); 062 063 String finalTag = provider.sanitizeTagName( tag ); 064 getLog().info( "Final Tag Name: '" + finalTag + "'" ); 065 066 CommandParameters parameters = new CommandParameters(); 067 parameters.setString( CommandParameter.TAG_NAME, finalTag ); 068 parameters.setString( CommandParameter.MESSAGE, message ); 069 070 UntagScmResult result = provider.untag( repository, getFileSet(), parameters ); 071 072 checkResult( result ); 073 } 074 catch ( IOException | ScmException e ) 075 { 076 throw new MojoExecutionException( "Cannot run untag command", e ); 077 } 078 } 079}