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.plugins.javadoc.stubs;
20  
21  import java.io.File;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.apache.maven.model.Build;
26  import org.apache.maven.model.Scm;
27  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
28  
29  /**
30   * Project stub for testing archive configuration.
31   */
32  public class JavadocJarArchiveConfigProjectStub extends MavenProjectStub {
33      private Scm scm;
34  
35      public JavadocJarArchiveConfigProjectStub() {
36          File projectFile = new File(getBasedir(), "javadocjar-archive-config.xml");
37          readModel(new File(getBasedir(), "javadocjar-archive-config.xml"));
38  
39          setFile(projectFile);
40  
41          setGroupId(getModel().getGroupId());
42          setArtifactId(getModel().getArtifactId());
43          setVersion(getModel().getVersion());
44          setName(getModel().getName());
45          setUrl(getModel().getUrl());
46          setPackaging(getModel().getPackaging());
47  
48          Scm scm = new Scm();
49          scm.setConnection("scm:svn:http://svn.apache.org/maven/sample/trunk");
50          setScm(scm);
51  
52          JavadocPluginArtifactStub artifact =
53                  new JavadocPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
54          artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
55          artifact.setType("jar");
56          artifact.setBaseVersion("1.0-SNAPSHOT");
57          setArtifact(artifact);
58  
59          Build build = new Build();
60          build.setFinalName("javadocjar-archive-config");
61          build.setDirectory(super.getBasedir() + "/target/test/unit/javadocjar-archive-config/target");
62          setBuild(build);
63  
64          List<String> compileSourceRoots = new ArrayList<>();
65          compileSourceRoots.add(getBasedir().getAbsolutePath());
66          setCompileSourceRoots(compileSourceRoots);
67      }
68  
69      /**
70       * {@inheritDoc}
71       */
72      @Override
73      public Scm getScm() {
74          return scm;
75      }
76  
77      /**
78       * {@inheritDoc}
79       */
80      @Override
81      public void setScm(Scm scm) {
82          this.scm = scm;
83      }
84  
85      /**
86       * {@inheritDoc}
87       */
88      @Override
89      public File getBasedir() {
90          return new File(super.getBasedir() + "/src/test/resources/unit/javadocjar-archive-config");
91      }
92  }