01: package org.andromda.maven.plugin.andromdapp;
02:
03: import java.net.URL;
04:
05: import org.andromda.andromdapp.AndroMDApp;
06: import org.andromda.core.common.ResourceUtils;
07: import org.apache.maven.plugin.MojoExecutionException;
08:
09: /**
10: * AndroMDA application generator Mojo.
11: *
12: * @author Chad Brandon
13: * @goal generate
14: * @requiresProject false
15: * @requiresDependencyResolution
16: */
17: public class AndroMDAppMojo extends AbstractAndroMDAppMojo {
18: /**
19: * An AndroMDApp configuration that contains some internal configuration information (like the AndroMDA
20: * version, etc).
21: */
22: private static final String INTERNAL_CONFIGURATION_URI = "META-INF/andromdapp/configuration.xml";
23:
24: /**
25: * @see org.apache.maven.plugin.Mojo#execute()
26: */
27: public void execute() throws MojoExecutionException {
28: try {
29: AndroMDApp andromdapp = new AndroMDApp();
30: final URL internalConfiguration = ResourceUtils
31: .getResource(INTERNAL_CONFIGURATION_URI);
32: if (internalConfiguration == null) {
33: throw new MojoExecutionException(
34: "No configuration could be loaded from --> '"
35: + INTERNAL_CONFIGURATION_URI + "'");
36: }
37: andromdapp.addConfigurationUri(internalConfiguration
38: .toString());
39: final String configuration = this
40: .getConfigurationContents();
41: if (configuration != null) {
42: andromdapp.addConfiguration(this
43: .getConfigurationContents());
44: }
45: andromdapp.run();
46: } catch (final Throwable throwable) {
47: if (throwable instanceof MojoExecutionException) {
48: throw (MojoExecutionException) throwable;
49: }
50: throw new MojoExecutionException(
51: "An error occurred while attempting to generate an application",
52: throwable);
53: }
54: }
55: }
|