1   package org.apache.maven.plugins.pdf.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.io.FileReader;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import org.apache.maven.artifact.repository.ArtifactRepository;
28  import org.apache.maven.artifact.repository.DefaultArtifactRepository;
29  import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
30  import org.apache.maven.model.Model;
31  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
32  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
33  
34  /**
35   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
36   * @version $Id: DefaultMavenProjectStub.java 780233 2009-05-30 10:59:10Z vsiveton $
37   */
38  public class DefaultMavenProjectStub
39      extends MavenProjectStub
40  {
41      public DefaultMavenProjectStub()
42      {
43          MavenXpp3Reader pomReader = new MavenXpp3Reader();
44          try
45          {
46              Model model = pomReader.read( new FileReader( new File( getBasedir() + "/pom.xml" ) ) );
47              setModel( model );
48          }
49          catch ( Exception e )
50          {
51              throw new RuntimeException( e );
52          }
53      }
54  
55      /** {@inheritDoc} */
56      public String getName()
57      {
58          return getModel().getName();
59      }
60  
61      /** {@inheritDoc} */
62      public File getBasedir()
63      {
64          return new File( super.getBasedir() + "/target/test-classes/unit/pdf/" );
65      }
66  
67      /** {@inheritDoc} */
68      public List getRemoteArtifactRepositories()
69      {
70          ArtifactRepository repository =
71              new DefaultArtifactRepository( "central", "http://repo1.maven.org/maven2",
72                                             new DefaultRepositoryLayout() );
73  
74          return Collections.singletonList( repository );
75      }
76  }