View Javadoc
1   package org.andromda.maven.plugin.andromdanetapp;
2   
3   import org.andromda.maven.plugin.andromdapp.AndroMDAppMojo;
4   
5   import org.andromda.andromdapp.AndroMDApp;
6   import org.andromda.core.common.ResourceUtils;
7   import org.apache.maven.plugin.MojoExecutionException;
8   import java.net.URL;
9   
10  /**
11   * The AndroMDAapp mojo (this should be extended by any Mojo that
12   * executes AndroMDApp.
13   *
14   * @author Chad Brandon
15   * @goal generate
16   * @requiresProject false
17   */
18  public class AndroMDANetAppMojo
19      extends AndroMDAppMojo
20  {
21      /**
22       * An AndroMDApp configuration that contains some internal configuration information (like the AndroMDA
23       * version, etc).
24       */
25      private static final String INTERNAL_CONFIGURATION_URI = "META-INF/andromdapp/configuration.xml";
26  
27  
28      /**
29       * @see org.apache.maven.plugin.Mojo#execute()
30       */
31      public void execute()
32          throws MojoExecutionException
33      {
34          try
35          {
36              AndroMDApp andromdapp = new AndroMDApp();
37  
38              final URL internalConfiguration = ResourceUtils.getResource(INTERNAL_CONFIGURATION_URI);
39              if (internalConfiguration == null)
40              {
41                  throw new MojoExecutionException("No configuration could be loaded from --> '" +
42                      INTERNAL_CONFIGURATION_URI + "'");
43              }
44              andromdapp.addConfigurationUri(internalConfiguration.toString());
45              final String configuration = this.getConfigurationContents();
46              if (configuration != null)
47              {
48                  andromdapp.addConfiguration(this.getConfigurationContents());
49              }
50              andromdapp.run();
51  
52          }
53          catch (final Throwable throwable)
54          {
55              if (throwable instanceof MojoExecutionException)
56              {
57                  throw (MojoExecutionException)throwable;
58              }
59              throw new MojoExecutionException("An error occurred while attempting to generate an application", throwable);
60          }
61      }
62  
63  }