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