View Javadoc
1   package org.apache.maven.plugins.source;
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.util.Collections;
23  import java.util.List;
24  
25  /*
26   * Licensed to the Apache Software Foundation (ASF) under one
27   * or more contributor license agreements.  See the NOTICE file
28   * distributed with this work for additional information
29   * regarding copyright ownership.  The ASF licenses this file
30   * to you under the Apache License, Version 2.0 (the
31   * "License"); you may not use this file except in compliance
32   * with the License.  You may obtain a copy of the License at
33   *
34   *   http://www.apache.org/licenses/LICENSE-2.0
35   *
36   * Unless required by applicable law or agreed to in writing,
37   * software distributed under the License is distributed on an
38   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
39   * KIND, either express or implied.  See the License for the
40   * specific language governing permissions and limitations
41   * under the License.
42   */
43  
44  import org.apache.maven.model.Resource;
45  import org.apache.maven.plugins.annotations.LifecyclePhase;
46  import org.apache.maven.plugins.annotations.Mojo;
47  import org.apache.maven.plugins.annotations.Parameter;
48  import org.apache.maven.project.MavenProject;
49  
50  /**
51   * This goal bundles all the test sources into a jar archive.  This goal functions the same
52   * as the test-jar goal but does not fork the build, and is suitable for attaching
53   * to the build lifecycle.
54   *
55   * @since 2.1
56   */
57  @Mojo( name = "test-jar-no-fork", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true )
58  public class TestSourceJarNoForkMojo
59      extends AbstractSourceJarMojo
60  {
61      /**
62       * @since 2.2
63       */
64      @Parameter( property = "maven.source.test.classifier", defaultValue = "test-sources" )
65      protected String classifier;
66  
67      /**
68       * {@inheritDoc}
69       */
70      protected List<String> getSources( MavenProject p )
71      {
72          return p.getTestCompileSourceRoots();
73      }
74  
75      /**
76       * {@inheritDoc}
77       */
78      protected List<Resource> getResources( MavenProject p )
79      {
80          if ( excludeResources )
81          {
82              return Collections.emptyList();
83          }
84  
85          return p.getTestResources();
86      }
87  
88      /**
89       * {@inheritDoc}
90       */
91      protected String getClassifier()
92      {
93          return classifier;
94      }
95  }