01: package org.andromda.maven.plugin.andromdapp;
02:
03: import java.io.File;
04:
05: import org.apache.maven.plugin.AbstractMojo;
06: import org.apache.maven.plugin.MojoExecutionException;
07: import org.apache.maven.project.MavenProject;
08:
09: /**
10: * An abstract Mojo for app server management.
11: *
12: * @author Chad Brandon
13: */
14: public abstract class AppManagementMojo extends AbstractMojo {
15: /**
16: * The location (i.e. path) to deploy.
17: *
18: * @parameter
19: * @required
20: */
21: protected String deployLocation;
22:
23: /**
24: * @parameter expression="${project}"
25: * @required
26: * @readonly
27: */
28: protected MavenProject project;
29:
30: /**
31: * Attempts to retrieve the packaging of the current project, and if it can't
32: * find it, throws an exception.
33: *
34: * @return the packaging.
35: * @throws MojoExecutionException if no packaging was found.
36: */
37: protected String getPackaging() throws MojoExecutionException {
38: final String packaging = this .project.getPackaging();
39: if (packaging == null || packaging.trim().length() == 0) {
40: throw new MojoExecutionException(
41: "This project must have the packaging defined, when attempting to deploy exploded");
42: }
43: return packaging;
44: }
45:
46: /**
47: * Retrieves the file that will be or is deployed.
48: *
49: * @return the deploy file.
50: * @throws MojoExecutionException
51: */
52: protected File getDeployFile() throws MojoExecutionException {
53: return new File(this .deployLocation, this .project.getBuild()
54: .getFinalName()
55: + '.' + this.getPackaging());
56: }
57: }
|