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