View Javadoc
1   package org.apache.maven.plugin.doap.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 java.io.File;
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.apache.maven.artifact.repository.ArtifactRepository;
27  import org.apache.maven.artifact.repository.DefaultArtifactRepository;
28  import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
29  import org.apache.maven.model.Developer;
30  import org.apache.maven.model.DistributionManagement;
31  import org.apache.maven.model.IssueManagement;
32  import org.apache.maven.model.License;
33  import org.apache.maven.model.Model;
34  import org.apache.maven.model.Organization;
35  import org.apache.maven.model.Scm;
36  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
37  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
38  import org.codehaus.plexus.util.ReaderFactory;
39  
40  /**
41   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
42   * @version $Id: AsfDoapProjectStub.java 1056464 2011-01-07 19:09:14Z vsiveton $
43   */
44  public class AsfDoapProjectStub
45      extends MavenProjectStub
46  {
47      private Model model;
48  
49      /**
50       * Default constructor
51       */
52      public AsfDoapProjectStub()
53      {
54          MavenXpp3Reader pomReader = new MavenXpp3Reader();
55          try
56          {
57              model =
58                  pomReader.read( ReaderFactory.newXmlReader( new File(
59                                                                        new File( super.getBasedir(),
60                                                                                  "/src/test/resources/unit/asf-doap-configuration/" ),
61                                                                        "asf-doap-configuration-plugin-config.xml" ) ) );
62              setModel( model );
63          }
64          catch ( Exception e )
65          {
66              throw new RuntimeException( e );
67          }
68  
69          setGroupId( model.getGroupId() );
70          setArtifactId( model.getArtifactId() );
71          setVersion( model.getVersion() );
72          setName( model.getName() );
73          setDescription( model.getDescription() );
74          setUrl( model.getUrl() );
75          setPackaging( model.getPackaging() );
76          setDevelopers( model.getDevelopers() );
77      }
78  
79      @Override
80      public List<Developer> getDevelopers()
81      {
82          return model.getDevelopers();
83      }
84  
85      @Override
86      public List<License> getLicenses()
87      {
88          return model.getLicenses();
89      }
90  
91      @Override
92      public Organization getOrganization()
93      {
94          return model.getOrganization();
95      }
96  
97      @Override
98      public Scm getScm()
99      {
100         return model.getScm();
101     }
102 
103     @Override
104     public IssueManagement getIssueManagement()
105     {
106         return model.getIssueManagement();
107     }
108 
109     @Override
110     public String getDescription()
111     {
112         return model.getDescription();
113     }
114 
115     @Override
116     public String getInceptionYear()
117     {
118         return model.getInceptionYear();
119     }
120 
121     @Override
122     public DistributionManagement getDistributionManagement()
123     {
124         return model.getDistributionManagement();
125     }
126 
127     @Override
128     public List<ArtifactRepository> getRemoteArtifactRepositories()
129     {
130         ArtifactRepository repository =
131             new DefaultArtifactRepository( "central", "http://repo2.maven.org/maven2/", new DefaultRepositoryLayout() );
132 
133         return Collections.singletonList( repository );
134     }
135 }