View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugin.doap.stubs;
20  
21  import java.io.File;
22  import java.util.Collections;
23  import java.util.List;
24  
25  import org.apache.maven.artifact.repository.ArtifactRepository;
26  import org.apache.maven.artifact.repository.DefaultArtifactRepository;
27  import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
28  import org.apache.maven.model.Developer;
29  import org.apache.maven.model.DistributionManagement;
30  import org.apache.maven.model.IssueManagement;
31  import org.apache.maven.model.License;
32  import org.apache.maven.model.Model;
33  import org.apache.maven.model.Organization;
34  import org.apache.maven.model.Scm;
35  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
36  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
37  import org.codehaus.plexus.util.ReaderFactory;
38  
39  /**
40   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
41   */
42  public class AsfDoapProjectStub extends MavenProjectStub {
43      private Model model;
44  
45      /**
46       * Default constructor
47       */
48      public AsfDoapProjectStub() {
49          MavenXpp3Reader pomReader = new MavenXpp3Reader();
50          try {
51              model = pomReader.read(ReaderFactory.newXmlReader(new File(
52                      new File(super.getBasedir(), "/src/test/resources/unit/asf-doap-configuration/"),
53                      "asf-doap-configuration-plugin-config.xml")));
54              setModel(model);
55          } catch (Exception e) {
56              throw new RuntimeException(e);
57          }
58  
59          setGroupId(model.getGroupId());
60          setArtifactId(model.getArtifactId());
61          setVersion(model.getVersion());
62          setName(model.getName());
63          setDescription(model.getDescription());
64          setUrl(model.getUrl());
65          setPackaging(model.getPackaging());
66          setDevelopers(model.getDevelopers());
67      }
68  
69      @Override
70      public List<Developer> getDevelopers() {
71          return model.getDevelopers();
72      }
73  
74      @Override
75      public List<License> getLicenses() {
76          return model.getLicenses();
77      }
78  
79      @Override
80      public Organization getOrganization() {
81          return model.getOrganization();
82      }
83  
84      @Override
85      public Scm getScm() {
86          return model.getScm();
87      }
88  
89      @Override
90      public IssueManagement getIssueManagement() {
91          return model.getIssueManagement();
92      }
93  
94      @Override
95      public String getDescription() {
96          return model.getDescription();
97      }
98  
99      @Override
100     public String getInceptionYear() {
101         return model.getInceptionYear();
102     }
103 
104     @Override
105     public DistributionManagement getDistributionManagement() {
106         return model.getDistributionManagement();
107     }
108 
109     @Override
110     public List<ArtifactRepository> getRemoteArtifactRepositories() {
111         ArtifactRepository repository = new DefaultArtifactRepository(
112                 "central", "https://repo.maven.apache.org/maven2", new DefaultRepositoryLayout());
113 
114         return Collections.singletonList(repository);
115     }
116 }