View Javadoc
1   package org.apache.maven.plugin.install.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 org.apache.maven.artifact.handler.ArtifactHandler;
23  import org.apache.maven.artifact.handler.DefaultArtifactHandler;
24  import org.apache.maven.artifact.metadata.ArtifactMetadata;
25  import org.apache.maven.plugin.testing.stubs.ArtifactStub;
26  
27  import java.io.File;
28  import java.util.Collection;
29  import java.util.Collections;
30  import java.util.HashMap;
31  import java.util.Map;
32  
33  
34  public class InstallArtifactStub
35      extends ArtifactStub
36  {
37      private Map<Object, ArtifactMetadata> metadataMap;
38  
39      private File file;
40  
41      private boolean release;
42  
43      public String getArtifactId()
44      {
45          return "maven-install-test";
46      }
47  
48      public String getGroupId()
49      {
50          return "org.apache.maven.test";
51      }
52  
53      public String getVersion()
54      {
55          return "1.0-SNAPSHOT";
56      }
57  
58      public String getBaseVersion()
59      {
60          return getVersion();
61      }
62  
63      public void setFile( File file )
64      {
65          this.file = file;
66      }
67  
68      public File getFile()
69      {
70          return file;
71      }
72  
73      public ArtifactHandler getArtifactHandler()
74      {
75          return new DefaultArtifactHandler()
76          {
77              public String getExtension()
78              {
79                  return "jar";
80              }
81          };
82      }
83  
84      public void addMetadata( ArtifactMetadata metadata )
85      {
86          if ( metadataMap == null )
87          {
88              metadataMap = new HashMap<Object, ArtifactMetadata>();
89          }
90  
91          ArtifactMetadata m = metadataMap.get( metadata.getKey() );
92          if ( m != null )
93          {
94              m.merge( metadata );
95          }
96          else
97          {
98              metadataMap.put( metadata.getKey(), metadata );
99          }
100     }
101 
102     public Collection getMetadataList()
103     {
104         return metadataMap == null ? Collections.EMPTY_LIST : metadataMap.values();
105     }
106 
107     public boolean isRelease()
108     {
109         return release;
110     }
111 
112     public void setRelease( boolean release )
113     {
114         this.release = release;
115     }
116 }