View Javadoc
1   package org.apache.maven.plugin.war.stub;
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 org.apache.maven.artifact.Artifact;
23  import org.apache.maven.model.Dependency;
24  import org.apache.maven.plugin.testing.stubs.ArtifactStub;
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  import java.util.Set;
29  import java.util.TreeSet;
30  
31  public class MavenProjectArtifactsStub
32      extends MavenProjectBasicStub
33  {
34      TreeSet<Artifact> artifacts;
35  
36      public MavenProjectArtifactsStub()
37          throws Exception
38      {
39          artifacts = new TreeSet<Artifact>();
40      }
41  
42      public void addArtifact( ArtifactStub stub )
43      {
44          artifacts.add( stub );
45      }
46  
47      public Set<Artifact> getArtifacts()
48      {
49          return artifacts;
50      }
51  
52      public List<Dependency> getDependencies()
53      {
54          if ( getArtifacts() == null )
55          {
56              return new ArrayList<Dependency>();
57          }
58          final List<Dependency> dependencies = new ArrayList<Dependency>();
59          for (Object o : getArtifacts()) {
60              Artifact a = (Artifact) o;
61              Dependency dependency = new Dependency();
62              dependency.setArtifactId(a.getArtifactId());
63              dependency.setGroupId(a.getGroupId());
64              dependency.setVersion(a.getVersion());
65              dependency.setScope(a.getScope());
66              dependency.setType(a.getType());
67              dependency.setClassifier(a.getClassifier());
68              dependencies.add(dependency);
69  
70          }
71          return dependencies;
72  
73      }
74  
75      public List<String> getRuntimeClasspathElements()
76      {
77          List<String> artifacts = new ArrayList<String>();
78  
79          artifacts.add(
80              "src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar" );
81          artifacts.add(
82              "src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar" );
83  
84          return artifacts;
85      }
86  }