19
19
package org .apache .maven .plugins .site .stubs ;
20
20
21
21
import java .io .File ;
22
+ import java .io .FileInputStream ;
23
+ import java .io .IOException ;
24
+ import java .io .InputStream ;
22
25
import java .util .Properties ;
23
26
24
27
import org .apache .maven .model .DistributionManagement ;
25
28
import org .apache .maven .model .Site ;
26
29
import org .apache .maven .model .io .xpp3 .MavenXpp3Reader ;
27
30
import org .apache .maven .plugin .testing .stubs .MavenProjectStub ;
28
- import org .codehaus .plexus .util .IOUtil ;
29
- import org .codehaus .plexus .util .ReaderFactory ;
30
- import org .codehaus .plexus .util .xml .XmlStreamReader ;
31
+ import org .codehaus .plexus .util .xml .pull .XmlPullParserException ;
31
32
32
33
/**
33
34
* @author <a href="mailto:[email protected] ">Vincent Siveton</a>
@@ -41,31 +42,29 @@ public class SiteMavenProjectStub extends MavenProjectStub {
41
42
public SiteMavenProjectStub (String projectName ) {
42
43
basedir = new File (super .getBasedir () + "/src/test/resources/unit/" + projectName );
43
44
44
- XmlStreamReader reader = null ;
45
- try {
46
- reader = ReaderFactory .newXmlReader (new File (getBasedir (), "pom.xml" ));
47
- setModel (new MavenXpp3Reader ().read (reader ));
48
- reader .close ();
49
- } catch (Exception e ) {
45
+ File pom = new File (getBasedir (), "pom.xml" );
46
+ try (InputStream in = new FileInputStream (pom )) {
47
+ setModel (new MavenXpp3Reader ().read (in ));
48
+ Site site = new Site ();
49
+ site .setId ("localhost" );
50
+ distributionManagement .setSite (site );
51
+ } catch (IOException | XmlPullParserException e ) {
50
52
throw new RuntimeException (e );
51
- } finally {
52
- IOUtil .close (reader );
53
53
}
54
- Site site = new Site ();
55
- site .setId ("localhost" );
56
- distributionManagement .setSite (site );
57
54
}
58
55
59
56
/**
60
57
* @see org.apache.maven.project.MavenProject#getName()
61
58
*/
59
+ @ Override
62
60
public String getName () {
63
61
return getModel ().getName ();
64
62
}
65
63
66
64
/**
67
65
* @see org.apache.maven.project.MavenProject#getProperties()
68
66
*/
67
+ @ Override
69
68
public Properties getProperties () {
70
69
return new Properties ();
71
70
}
@@ -76,6 +75,7 @@ public DistributionManagement getDistributionManagement() {
76
75
}
77
76
78
77
/** {@inheritDoc} */
78
+ @ Override
79
79
public File getBasedir () {
80
80
return basedir ;
81
81
}
0 commit comments