View Javadoc
1   package org.apache.maven.plugins.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<Object, ArtifactMetadata> 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      @Override
65      public String getType()
66      {
67          return "jar";
68      }
69      
70      public void setFile( File file )
71      {
72          this.file = file;
73      }
74      
75      public File getFile()
76      {
77          return file;
78      }
79      
80      public ArtifactHandler getArtifactHandler()
81      {
82          return new DefaultArtifactHandler()
83          {
84              public String getExtension()
85              {
86                  if( extension == null )
87                  {
88                      extension = "jar";
89                  }
90                  return extension;
91              }
92          };
93      }
94      
95      public void setArtifactHandlerExtension( String extension )
96      {
97          this.extension = extension;
98      }
99      
100     public void addMetadata( ArtifactMetadata metadata )
101     {
102         if ( metadataMap == null )
103         {
104             metadataMap = new HashMap<Object, ArtifactMetadata>();
105         }
106 
107         ArtifactMetadata m = metadataMap.get( metadata.getKey() );
108         if ( m != null )
109         {
110             m.merge( metadata );
111         }
112         else
113         {
114             metadataMap.put( metadata.getKey(), metadata );
115         }
116     }
117     
118     public Collection<ArtifactMetadata> getMetadataList()
119     {
120         return metadataMap == null ? Collections.<ArtifactMetadata>emptyList() : metadataMap.values();
121     }
122 
123     public boolean isRelease()
124     {
125         return release;
126     }
127 
128     public void setRelease( boolean release )
129     {
130         this.release = release;
131     }
132 
133     /*
134     public boolean isSnapshot()
135     {
136         return false;
137     }
138     */
139 }