View Javadoc
1   package org.apache.maven.plugins.checkstyle.stubs;
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 org.apache.maven.model.Build;
23  import org.apache.maven.model.Organization;
24  import org.apache.maven.model.ReportPlugin;
25  import org.apache.maven.artifact.DependencyResolutionRequiredException;
26  import org.codehaus.plexus.PlexusTestCase;
27  
28  import java.util.ArrayList;
29  import java.util.List;
30  import java.util.Collections;
31  import java.io.File;
32  
33  /**
34   * @author Edwin Punzalan
35   * @version $Id$
36   */
37  public class ModuleMavenProjectStub
38      extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
39  {
40  
41      /** {@inheritDoc} */
42      public List<String> getCompileClasspathElements()
43          throws DependencyResolutionRequiredException
44      {
45          return getCompileSourceRoots();
46      }
47  
48      /** {@inheritDoc} */
49      public List<String> getTestClasspathElements()
50          throws DependencyResolutionRequiredException
51      {
52          List<String> list = new ArrayList<>( getCompileClasspathElements() );
53          list.add( PlexusTestCase.getBasedir() + "/target/test-classes" );
54          return list;
55      }
56  
57      /** {@inheritDoc} */
58      public List<String> getCompileSourceRoots()
59      {
60          return Collections.singletonList( PlexusTestCase.getBasedir() + "/target/classes" );
61      }
62  
63      /** {@inheritDoc} */
64      public List<String> getTestCompileSourceRoots()
65      {
66          List<String> list = new ArrayList<>( getCompileSourceRoots() );
67          list.add( PlexusTestCase.getBasedir() + "/target/test-classes" );
68          return list;
69      }
70  
71      /** {@inheritDoc} */
72      public File getBasedir()
73      {
74          return new File( PlexusTestCase.getBasedir() );
75      }
76  
77      /** {@inheritDoc} */
78      public List<ReportPlugin> getReportPlugins()
79      {
80          ReportPlugin jxrPlugin = new ReportPlugin();
81  
82          jxrPlugin.setArtifactId( "maven-jxr-plugin" );
83  
84          return Collections.singletonList( jxrPlugin );
85      }
86  
87      /** {@inheritDoc} */
88      public Organization getOrganization()
89      {
90          Organization organization = new Organization();
91  
92          organization.setName( "maven-plugin-tests" );
93  
94          return organization;
95      }
96  
97      /** {@inheritDoc} */
98      public String getInceptionYear()
99      {
100         return "2006";
101     }
102 
103     /** {@inheritDoc} */
104     public Build getBuild()
105     {
106         Build build = new Build();
107 
108         build.setDirectory( PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi" );
109         build.setSourceDirectory( PlexusTestCase.getBasedir() + "/src/test/test-sources" );
110         build.setTestSourceDirectory( PlexusTestCase.getBasedir() + "/src/test/java" );
111 
112         return build;
113     }
114 
115     /** {@inheritDoc} */
116     public File getFile()
117     {
118         File file = new File( getBasedir(), "pom.xml" );
119 
120         return file;
121     }
122 }