UndeployMojo.java :  » UML » AndroMDA-3.2 » org » andromda » maven » plugin » andromdapp » Java Open Source

Java Open Source » UML » AndroMDA 3.2 
AndroMDA 3.2 » org » andromda » maven » plugin » andromdapp » UndeployMojo.java
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");
        }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.