Package org.andromda.maven.plugin.andromdapp

Source Code of org.andromda.maven.plugin.andromdapp.UndeployMojo

package org.andromda.maven.plugin.andromdapp;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;


/**
* Provides the undeployment of applications from a given directory.
*
* @goal undeploy
* @author Chad Brandon
*/
public class UndeployMojo
    extends AppManagementMojo
{
    /**
     * @see org.apache.maven.plugin.AbstractMojo#execute()
     */
    public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        final File deployDirectory = new File(this.deployLocation);
        if (deployDirectory.exists() && deployDirectory.isDirectory())
        {
            try
            {
                final File deployFile = this.getDeployFile();
                this.getLog().info("Undeploying " + deployFile + " from " + deployDirectory);
                if (deployFile.isDirectory())
                {
                    FileUtils.deleteDirectory(deployFile);
                }
                else
                {
                    deployFile.delete();
                }
            }
            catch (final Throwable throwable)
            {
                throw new MojoExecutionException("An error occurred while attempting to undeploy artifact", throwable);
            }
        }
        else
        {
            this.getLog().warn(
                "Undeploy did not occur because the specified deployLocation '" + deployLocation +
                "' does not exist, or is not a directory");
        }
    }
}
TOP

Related Classes of org.andromda.maven.plugin.andromdapp.UndeployMojo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.