1 package org.codehaus.mojo.apt;
2
3 /*
4 * The MIT License
5 *
6 * Copyright 2006-2008 The Codehaus.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy of
9 * this software and associated documentation files (the "Software"), to deal in
10 * the Software without restriction, including without limitation the rights to
11 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 * of the Software, and to permit persons to whom the Software is furnished to do
13 * so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in all
16 * copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27 import java.io.File;
28 import java.util.List;
29 import java.util.Set;
30
31 import org.apache.maven.model.Resource;
32
33 /**
34 * Executes apt on project test sources.
35 *
36 * @author <a href="mailto:jubu@codehaus.org">Juraj Burian</a>
37 * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
38 * @version $Id: TestProcessMojo.java 11632 2010-01-12 17:17:35Z mark $
39 * @goal test-process
40 * @phase generate-test-resources
41 * @requiresDependencyResolution test
42 */
43 public class TestProcessMojo extends AbstractAptMojo
44 {
45 // read-only parameters ---------------------------------------------------
46
47 /**
48 * The source directories containing the test sources to be processed.
49 *
50 * @parameter expression="${project.testCompileSourceRoots}"
51 * @required
52 * @readonly
53 */
54 private List<String> testCompileSourceRoots;
55
56 /**
57 * The project's test resources.
58 *
59 * @parameter expression="${project.testResources}"
60 * @required
61 * @readonly
62 */
63 private List<Resource> testResources;
64
65 /**
66 * The project's test classpath.
67 *
68 * @parameter expression="${project.testClasspathElements}"
69 * @required
70 * @readonly
71 */
72 private List<String> testClasspathElements;
73
74 // configurable parameters ------------------------------------------------
75
76 /**
77 * A list of inclusion filters for apt. Default value is <code>**/*.java</code>.
78 *
79 * @parameter
80 */
81 private Set<String> includes;
82
83 /**
84 * A list of exclusion filters for apt.
85 *
86 * @parameter
87 */
88 private Set<String> excludes;
89
90 /**
91 * The directory to place processor and generated class files. This is equivalent to the <code>-d</code> argument
92 * for apt.
93 *
94 * @parameter default-value="${project.build.directory}/generated-test-resources/apt"
95 */
96 private File testOutputDirectory;
97
98 /**
99 * The directory root under which processor-generated test source files will be placed; files are placed in
100 * subdirectories based on package namespace. This is equivalent to the <code>-s</code> argument for apt.
101 *
102 * @parameter default-value="${project.build.directory}/generated-test-sources/apt"
103 */
104 private File testSourceOutputDirectory;
105
106 // AbstractAptMojo methods ------------------------------------------------
107
108 /**
109 * {@inheritDoc}
110 */
111 @Override
112 protected List<String> getCompileSourceRoots()
113 {
114 return testCompileSourceRoots;
115 }
116
117 /**
118 * {@inheritDoc}
119 */
120 @Override
121 protected List<Resource> getResources()
122 {
123 return testResources;
124 }
125
126 /**
127 * {@inheritDoc}
128 */
129 @Override
130 protected List<String> getClasspathElements()
131 {
132 return testClasspathElements;
133 }
134
135 /**
136 * {@inheritDoc}
137 */
138 @Override
139 protected Set<String> getIncludes()
140 {
141 return includes;
142 }
143
144 /**
145 * {@inheritDoc}
146 */
147 @Override
148 protected Set<String> getExcludes()
149 {
150 return excludes;
151 }
152
153 /**
154 * {@inheritDoc}
155 */
156 @Override
157 protected File getOutputDirectory()
158 {
159 return testOutputDirectory;
160 }
161
162 /**
163 * {@inheritDoc}
164 */
165 @Override
166 protected File getSourceOutputDirectory()
167 {
168 return testSourceOutputDirectory;
169 }
170 }