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.remove.RemoveScmResult; 030import org.apache.maven.scm.manager.ScmManager; 031import org.apache.maven.scm.repository.ScmRepository; 032import org.apache.maven.settings.crypto.SettingsDecrypter; 033 034/** 035 * Mark a set of files for deletion. 036 * 037 * @author <a href="paul@webotech.co.uk">Paul Mackinlay</a> 038 */ 039@Mojo(name = "remove", aggregator = true) 040public class RemoveMojo extends AbstractScmMojo { 041 042 /** 043 * The commit message. 044 */ 045 @Parameter(property = "message") 046 private String message; 047 048 @Inject 049 public RemoveMojo(ScmManager manager, SettingsDecrypter settingsDecrypter) { 050 super(manager, settingsDecrypter); 051 } 052 053 /** 054 * {@inheritDoc} 055 */ 056 public void execute() throws MojoExecutionException { 057 super.execute(); 058 try { 059 ScmRepository repository = getScmRepository(); 060 RemoveScmResult result = getScmManager().remove(repository, getFileSet(), message); 061 checkResult(result); 062 } catch (IOException | ScmException e) { 063 throw new MojoExecutionException("Cannot run remove command : " + e.getMessage(), e); 064 } 065 } 066}