001package org.andromda.maven.plugin.andromdanetapp; 002 003import org.andromda.maven.plugin.andromdapp.AndroMDAppMojo; 004 005import org.andromda.andromdapp.AndroMDApp; 006import org.andromda.core.common.ResourceUtils; 007import org.apache.maven.plugin.MojoExecutionException; 008import java.net.URL; 009 010/** 011 * The AndroMDAapp mojo (this should be extended by any Mojo that 012 * executes AndroMDApp. 013 * 014 * @author Chad Brandon 015 * @goal generate 016 * @requiresProject false 017 */ 018public class AndroMDANetAppMojo 019 extends AndroMDAppMojo 020{ 021 /** 022 * An AndroMDApp configuration that contains some internal configuration information (like the AndroMDA 023 * version, etc). 024 */ 025 private static final String INTERNAL_CONFIGURATION_URI = "META-INF/andromdapp/configuration.xml"; 026 027 028 /** 029 * @see org.apache.maven.plugin.Mojo#execute() 030 */ 031 public void execute() 032 throws MojoExecutionException 033 { 034 try 035 { 036 AndroMDApp andromdapp = new AndroMDApp(); 037 038 final URL internalConfiguration = ResourceUtils.getResource(INTERNAL_CONFIGURATION_URI); 039 if (internalConfiguration == null) 040 { 041 throw new MojoExecutionException("No configuration could be loaded from --> '" + 042 INTERNAL_CONFIGURATION_URI + "'"); 043 } 044 andromdapp.addConfigurationUri(internalConfiguration.toString()); 045 final String configuration = this.getConfigurationContents(); 046 if (configuration != null) 047 { 048 andromdapp.addConfiguration(this.getConfigurationContents()); 049 } 050 andromdapp.run(); 051 052 } 053 catch (final Throwable throwable) 054 { 055 if (throwable instanceof MojoExecutionException) 056 { 057 throw (MojoExecutionException)throwable; 058 } 059 throw new MojoExecutionException("An error occurred while attempting to generate an application", throwable); 060 } 061 } 062 063}