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
12
13
14
15
16
17
18 public class AndroMDANetAppMojo
19 extends AndroMDAppMojo
20 {
21
22
23
24
25 private static final String INTERNAL_CONFIGURATION_URI = "META-INF/andromdapp/configuration.xml";
26
27
28
29
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 }