1 package org.codehaus.gmavenplus.mojo;
2
3 import org.apache.maven.artifact.DependencyResolutionRequiredException;
4 import org.apache.maven.plugin.MojoExecutionException;
5 import org.apache.maven.plugins.annotations.Mojo;
6 import org.apache.maven.plugins.annotations.Parameter;
7 import org.apache.maven.plugins.annotations.ResolutionScope;
8 import org.apache.maven.shared.model.fileset.FileSet;
9
10 import java.io.File;
11 import java.lang.reflect.InvocationTargetException;
12 import java.net.MalformedURLException;
13
14
15
16
17
18
19
20
21 @Mojo(name = "groovydocTests", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
22 public class GroovyDocTestsMojo extends AbstractGroovyDocMojo {
23
24
25
26
27
28 @Parameter
29 protected FileSet[] testSources;
30
31
32
33
34 @Parameter(defaultValue = "${project.build.directory}/testgapidocs")
35 protected File testGroovyDocOutputDirectory;
36
37
38
39
40
41
42 @Parameter(defaultValue = "true")
43 protected boolean testGroovyDocJavaSources;
44
45
46
47
48
49
50 @Override
51 public void execute() throws MojoExecutionException {
52 try {
53 try {
54 getLog().debug("Project test classpath:\n" + project.getCompileClasspathElements());
55 } catch (DependencyResolutionRequiredException e) {
56 getLog().debug("Unable to log project tset classpath");
57 }
58 doGroovyDocGeneration(getTestFilesets(testSources, testGroovyDocJavaSources), project.getTestClasspathElements(), testGroovyDocOutputDirectory);
59 } catch (ClassNotFoundException e) {
60 throw new MojoExecutionException("Unable to get a Groovy class from classpath (" + e.getMessage() + "). Do you have Groovy as a compile dependency in your project?", e);
61 } catch (InvocationTargetException e) {
62 throw new MojoExecutionException("Error occurred while calling a method on a Groovy class from classpath.", e);
63 } catch (InstantiationException e) {
64 throw new MojoExecutionException("Error occurred while instantiating a Groovy class from classpath.", e);
65 } catch (IllegalAccessException e) {
66 throw new MojoExecutionException("Unable to access a method on a Groovy class from classpath.", e);
67 } catch (DependencyResolutionRequiredException e) {
68 throw new MojoExecutionException("Test dependencies weren't resolved.", e);
69 } catch (MalformedURLException e) {
70 throw new MojoExecutionException("Unable to add project test dependencies to classpath.", e);
71 }
72 }
73
74 }