View Javadoc
1   package org.apache.maven.plugins.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 String getType()
74      {
75          return "jar";
76      }
77      
78      public ArtifactHandler getArtifactHandler()
79      {
80          return new DefaultArtifactHandler()
81          {
82              public String getExtension()
83              {
84                  return "jar";
85              }
86          };
87      }
88  
89      public void addMetadata( ArtifactMetadata metadata )
90      {
91          if ( metadataMap == null )
92          {
93              metadataMap = new HashMap<Object, ArtifactMetadata>();
94          }
95  
96          ArtifactMetadata m = metadataMap.get( metadata.getKey() );
97          if ( m != null )
98          {
99              m.merge( metadata );
100         }
101         else
102         {
103             metadataMap.put( metadata.getKey(), metadata );
104         }
105     }
106 
107     public Collection getMetadataList()
108     {
109         return metadataMap == null ? Collections.EMPTY_LIST : metadataMap.values();
110     }
111 
112     public boolean isRelease()
113     {
114         return release;
115     }
116 
117     public void setRelease( boolean release )
118     {
119         this.release = release;
120     }
121 }