1 package org.apache.maven.plugins.site.stubs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Properties;
24
25 import org.apache.maven.model.DistributionManagement;
26 import org.apache.maven.model.Model;
27 import org.apache.maven.model.Site;
28 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
29 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
30 import org.codehaus.plexus.util.ReaderFactory;
31
32
33
34
35
36 public class SiteMavenProjectStub
37 extends MavenProjectStub
38 {
39 DistributionManagement distributionManagement = new DistributionManagement();
40
41 public SiteMavenProjectStub()
42 {
43 this( null );
44 }
45
46 public SiteMavenProjectStub( String pomFilePath )
47 {
48 MavenXpp3Reader pomReader = new MavenXpp3Reader();
49 Model model;
50
51 try
52 {
53 File pomFile =
54 new File( getBasedir(), pomFilePath == null ? "/src/test/resources/unit/interpolated-site/pom.xml"
55 : pomFilePath );
56 model = pomReader.read( ReaderFactory.newXmlReader( pomFile ) );
57 setModel( model );
58 }
59 catch ( Exception e )
60 {
61 throw new RuntimeException( e );
62 }
63 Site site = new Site();
64 site.setId( "localhost" );
65 distributionManagement.setSite( site );
66 }
67
68
69
70
71 public String getName()
72 {
73 return getModel().getName();
74 }
75
76
77
78
79 public Properties getProperties()
80 {
81 return new Properties();
82 }
83
84 @Override
85 public DistributionManagement getDistributionManagement()
86 {
87 return distributionManagement;
88 }
89 }