AppManagementMojo.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 » AppManagementMojo.java
package org.andromda.maven.plugin.andromdapp;

import java.io.File;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;


/**
 * An abstract Mojo for app server management.
 *
 * @author Chad Brandon
 */
public abstract class AppManagementMojo
    extends AbstractMojo
{
    /**
     * The location (i.e. path) to deploy.
     *
     * @parameter
     * @required
     */
    protected String deployLocation;

    /**
     * @parameter expression="${project}"
     * @required
     * @readonly
     */
    protected MavenProject project;
    
    /**
     * Attempts to retrieve the packaging of the current project, and if it can't
     * find it, throws an exception.
     * 
     * @return the packaging.
     * @throws MojoExecutionException if no packaging was found.
     */
    protected String getPackaging() throws MojoExecutionException
    {
        final String packaging = this.project.getPackaging();
        if (packaging == null || packaging.trim().length() == 0)
        {
            throw new MojoExecutionException(
                "This project must have the packaging defined, when attempting to deploy exploded");
        }
        return packaging;
    }
    
    /**
     * Retrieves the file that will be or is deployed.
     * 
     * @return the deploy file.
     * @throws MojoExecutionException
     */
    protected File getDeployFile() throws MojoExecutionException
    {
        return new File(this.deployLocation, this.project.getBuild().getFinalName() + '.' + this.getPackaging());
    }
}
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.