1 package org.andromda.maven.plugin.andromdapp;
2
3 import java.net.URL;
4 import java.net.URLClassLoader;
5 import org.andromda.andromdapp.AndroMDApp;
6 import org.apache.maven.plugin.MojoExecutionException;
7
8
9
10
11
12
13
14
15 public class AndroMDAppCleanMojo
16 extends AbstractAndroMDAppMojo
17 {
18
19
20
21 public void execute()
22 throws MojoExecutionException
23 {
24 if (this.skipProcessing)
25 {
26 getLog().info("andromdapp:clean skipProcessing");
27 return;
28 }
29 try
30 {
31 final AndroMDApp andromdapp = new AndroMDApp();
32 final String configuration = this.getConfigurationContents();
33 if (configuration != null)
34 {
35 andromdapp.addConfiguration(this.getConfigurationContents());
36 }
37 andromdapp.clean();
38 }
39 catch (final NoClassDefFoundError ncdfe)
40 {
41 ClassLoader cl = this.getClass().getClassLoader();
42
43
44 System.err.println( "classloader:" + cl );
45 if ( cl instanceof URLClassLoader ) {
46 URLClassLoader ucl = (URLClassLoader) cl;
47 URL [] urls = ucl.getURLs();
48 for (URL url : urls) {
49 System.err.println("cp:" + url);
50 }
51 try
52 {
53 ucl.close();
54 }
55 catch (Exception ex)
56 {
57
58 }
59 }
60 System.out.println( "Exception:" + ncdfe );
61 ncdfe.printStackTrace(System.err);
62 Throwable th = ncdfe.getCause();
63 while ( th != null ) {
64 System.err.println( "================= cause =================");
65 th.printStackTrace(System.err);
66 th = th.getCause();
67 }
68 }
69 catch (final Throwable throwable)
70 {
71 if (throwable instanceof MojoExecutionException)
72 {
73 throw (MojoExecutionException)throwable;
74 }
75 throw new MojoExecutionException("An error occurred during application cleanup operation", throwable);
76 }
77 }
78 }