1 package org.apache.maven.plugin.pmd.stubs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.model.Build;
24 import org.apache.maven.model.Model;
25 import org.apache.maven.model.Scm;
26 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
27 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
28
29 import java.io.File;
30 import java.io.FileReader;
31 import java.util.ArrayList;
32 import java.util.List;
33
34
35
36
37
38 public class CustomConfigurationMavenProjectStub
39 extends MavenProjectStub
40 {
41 private Build build;
42
43 private List reportPlugins = new ArrayList();
44
45 public CustomConfigurationMavenProjectStub()
46 {
47 MavenXpp3Reader pomReader = new MavenXpp3Reader();
48 Model model = null;
49
50 try
51 {
52 model = pomReader.read( new FileReader( new File( getBasedir() +
53 "/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml" ) ) );
54 setModel( model );
55 }
56 catch ( Exception e )
57 {
58
59 }
60
61 setGroupId( model.getGroupId() );
62 setArtifactId( model.getArtifactId() );
63 setVersion( model.getVersion() );
64 setName( model.getName() );
65 setUrl( model.getUrl() );
66 setPackaging( model.getPackaging() );
67
68 Scm scm = new Scm();
69 scm.setConnection( "scm:svn:http://svn.apache.org/maven/sample/trunk" );
70 setScm( scm );
71
72 Build build = new Build();
73 build.setFinalName( model.getBuild().getFinalName() );
74 build.setDirectory( getBasedir() + "/target/test/unit/custom-configuration/target" );
75 build.setSourceDirectory( getBasedir() + "/src/test/resources/unit/custom-configuration" );
76 setBuild( build );
77
78 setReportPlugins( model.getReporting().getPlugins() );
79
80 String basedir = getBasedir().getAbsolutePath();
81 List compileSourceRoots = new ArrayList();
82 compileSourceRoots.add( basedir + "/src/test/resources/unit/custom-configuration/custom/configuration" );
83 setCompileSourceRoots( compileSourceRoots );
84
85 Artifact artifact = new PmdPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() );
86 artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
87 setArtifact( artifact );
88
89 setFile(new File(getBasedir().getAbsolutePath() + "/pom.xml"));
90 }
91
92
93 public void setBuild( Build build )
94 {
95 this.build = build;
96 }
97
98
99 public Build getBuild()
100 {
101 return build;
102 }
103
104 public void setReportPlugins( List plugins )
105 {
106 this.reportPlugins = plugins;
107 }
108
109
110 public List getReportPlugins()
111 {
112 return reportPlugins;
113 }
114
115 }