Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TestJarMojo |
|
| 1.25;1.25 |
1 | package org.apache.maven.plugin.jar; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.io.File; | |
23 | import org.apache.maven.plugin.MojoExecutionException; | |
24 | ||
25 | /** | |
26 | * Build a JAR of the test classes for the current project. | |
27 | * | |
28 | * @author <a href="evenisse@apache.org">Emmanuel Venisse</a> | |
29 | * @version $Id: TestJarMojo.java 1158941 2011-08-17 22:22:17Z rfscholte $ | |
30 | * @goal test-jar | |
31 | * @phase package | |
32 | * @requiresProject | |
33 | * @threadSafe | |
34 | * @requiresDependencyResolution test | |
35 | */ | |
36 | 0 | public class TestJarMojo |
37 | extends AbstractJarMojo | |
38 | { | |
39 | ||
40 | /** | |
41 | * Set this to <code>true</code> to bypass unit tests entirely. | |
42 | * Its use is <b>NOT RECOMMENDED</b>, but quite convenient on occasion. | |
43 | * | |
44 | * @parameter expression="${maven.test.skip}" | |
45 | */ | |
46 | private boolean skip; | |
47 | ||
48 | /** | |
49 | * Directory containing the test classes and resource files that should be packaged into the JAR. | |
50 | * | |
51 | * @parameter default-value="${project.build.testOutputDirectory}" | |
52 | * @required | |
53 | */ | |
54 | private File testClassesDirectory; | |
55 | ||
56 | protected String getClassifier() | |
57 | { | |
58 | 0 | return "tests"; |
59 | } | |
60 | ||
61 | /** | |
62 | * @return type of the generated artifact | |
63 | */ | |
64 | protected String getType() | |
65 | { | |
66 | 0 | return "test-jar"; |
67 | } | |
68 | ||
69 | /** | |
70 | * Return the test-classes directory, to serve as the root of the tests jar. | |
71 | */ | |
72 | protected File getClassesDirectory() | |
73 | { | |
74 | 0 | return testClassesDirectory; |
75 | } | |
76 | ||
77 | public void execute() | |
78 | throws MojoExecutionException | |
79 | { | |
80 | 0 | if ( skip ) |
81 | { | |
82 | 0 | getLog().info( "Skipping packaging of the test-jar" ); |
83 | } | |
84 | else | |
85 | { | |
86 | 0 | super.execute(); |
87 | } | |
88 | 0 | } |
89 | } |