All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.mojo.flatten.CleanMojo Maven / Gradle / Ivy

/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0 */
package org.codehaus.mojo.flatten;

import java.io.File;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;

/**
 * This MOJO realizes the goal flatten:clean that deletes any files created by
 * {@link FlattenMojo flatten:flatten} (more specific the flattened POM file which is by default
 * .flattened-pom.xml). See also MOJO-2030 for
 * further details.
 *
 * @author Joerg Hohwiller (hohwille at users.sourceforge.net)
 * @since 1.0.0-beta-2
 */
@Mojo( name = "clean", requiresProject = true, requiresDirectInvocation = false, executionStrategy = "once-per-session" )
public class CleanMojo
    extends AbstractFlattenMojo
{

    /**
     * The constructor.
     */
    public CleanMojo()
    {
        super();
    }

    /**
     * {@inheritDoc}
     */
    public void execute()
        throws MojoExecutionException, MojoFailureException
    {

        File flattenedPomFile = getFlattenedPomFile();
        if ( flattenedPomFile.isFile() )
        {
            getLog().info( "Deleting " + flattenedPomFile.getPath() );
            boolean deleted = flattenedPomFile.delete();
            if ( !deleted )
            {
                throw new MojoFailureException( "Could not delete " + flattenedPomFile.getAbsolutePath() );
            }
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy