1 package org.andromda.maven.plugin.site;
2
3 import java.io.File;
4 import org.apache.commons.lang.exception.ExceptionUtils;
5 import org.apache.maven.plugin.MojoExecutionException;
6 import org.apache.maven.plugin.MojoFailureException;
7 import org.apache.maven.project.MavenProject;
8
9
10
11
12
13
14
15
16
17
18 public class UnpackDocumentationMojo
19 extends AbstractSiteMojo
20 {
21
22
23
24
25
26 private File jmiApiSourcePath;
27
28
29
30
31
32
33 private File jmiApiOutputDirectory;
34
35
36
37
38
39
40 private File umlDocCarRentalSampleSourcePath;
41
42
43
44
45
46
47 private File umlDocCarRentalSampleOutputDirectory;
48
49
50
51
52
53
54 @SuppressWarnings("unused")
55 private String projectName;
56
57
58
59
60
61
62 protected MavenProject project;
63
64
65
66
67 public void execute()
68 throws MojoExecutionException, MojoFailureException
69 {
70 this.getLog().info("-----------------------------------------------------------------------------");
71 this.getLog().info(" A n d r o M D A S i t e D o c U n p a c k");
72 this.getLog().info("-----------------------------------------------------------------------------");
73
74 this.unpackUmlDocCarRentalSample();
75 this.unpackJmiApi();
76
77 this.getLog().info("SITE DOCUMENTATION UNPACK SUCCESSFUL");
78 }
79
80
81
82
83
84
85
86 private void unpackJmiApi()
87 throws MojoExecutionException, MojoFailureException
88 {
89 try
90 {
91 if (!this.jmiApiSourcePath.exists())
92 {
93 throw new MojoExecutionException("JMI API source location is invalid");
94 }
95
96 this.unpack(
97 this.jmiApiSourcePath,
98 this.jmiApiOutputDirectory);
99 }
100 catch (final Throwable throwable)
101 {
102 if (throwable instanceof MojoExecutionException)
103 {
104 throw (MojoExecutionException)throwable;
105 }
106 throw new MojoExecutionException("An error occurred unpacking JMI 1.4 API '" +
107 this.project.getArtifactId() + '\'',
108 ExceptionUtils.getRootCause(throwable));
109 }
110 }
111
112
113
114
115
116
117
118 private void unpackUmlDocCarRentalSample()
119 throws MojoExecutionException, MojoFailureException
120 {
121 try
122 {
123 if (!this.umlDocCarRentalSampleSourcePath.exists())
124 {
125 throw new MojoExecutionException("UmlDoc car-rental-sample source location is invalid");
126 }
127
128 this.unpack(
129 this.umlDocCarRentalSampleSourcePath,
130 this.umlDocCarRentalSampleOutputDirectory);
131 }
132 catch (final Throwable throwable)
133 {
134 if (throwable instanceof MojoExecutionException)
135 {
136 throw (MojoExecutionException)throwable;
137 }
138 throw new MojoExecutionException("An error occurred unpacking UmlDoc for car-rental-sample '" +
139 this.project.getArtifactId() + '\'',
140 ExceptionUtils.getRootCause(throwable));
141 }
142 }
143 }