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