View Javadoc

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