View Javadoc
1   package org.apache.maven.plugins.source.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.versioning.VersionRange;
24  import org.apache.maven.plugin.testing.stubs.ArtifactStub;
25  
26  /**
27   * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
28   */
29  public class SourcePluginArtifactStub
30      extends ArtifactStub
31  {
32  
33      private String groupId;
34  
35      private String artifactId;
36  
37      private String version;
38  
39      private String type;
40  
41      private String classifier;
42  
43      private String baseVersion;
44  
45      private VersionRange versionRange;
46  
47      private ArtifactHandler handler;
48  
49      public SourcePluginArtifactStub( String groupId, String artifactId, String version, String type, String classifier )
50      {
51          this.groupId = groupId;
52          this.artifactId = artifactId;
53          this.version = version;
54          this.type = type;
55          this.classifier = classifier;
56          versionRange = VersionRange.createFromVersion( version );
57      }
58  
59      public void setGroupId( String groupId )
60      {
61          this.groupId = groupId;
62      }
63  
64      public String getGroupId()
65      {
66          return groupId;
67      }
68  
69      public void setArtifactId( String artifactId )
70      {
71          this.artifactId = artifactId;
72      }
73  
74      public String getArtifactId()
75      {
76          return artifactId;
77      }
78  
79      public void setVersion( String version )
80      {
81          this.version = version;
82      }
83  
84      public String getVersion()
85      {
86          return version;
87      }
88  
89      public void setType( String packaging )
90      {
91          this.type = packaging;
92      }
93  
94      public String getType()
95      {
96          return type;
97      }
98  
99      public void setClassifier( String classifier )
100     {
101         this.classifier = classifier;
102     }
103 
104     public String getClassifier()
105     {
106         return classifier;
107     }
108 
109     public boolean hasClassifier()
110     {
111         return classifier != null;
112     }
113 
114     public String getId()
115     {
116         String id = groupId + ":" + artifactId + ":" + type + ":";
117 
118         if ( hasClassifier() )
119         {
120             id = id + getClassifier() + ":";
121         }
122 
123         id = id + version;
124 
125         return id;
126     }
127 
128     public VersionRange getVersionRange()
129     {
130         return versionRange;
131     }
132 
133     public void setVersionRange( VersionRange versionRange )
134     {
135         this.versionRange = versionRange;
136     }
137 
138     public String getBaseVersion()
139     {
140         return baseVersion;
141     }
142 
143     public void setBaseVersion( String baseVersion )
144     {
145         this.baseVersion = baseVersion;
146     }
147 
148     public ArtifactHandler getArtifactHandler()
149     {
150         return handler;
151     }
152 
153     public void setArtifactHandler( ArtifactHandler handler )
154     {
155         this.handler = handler;
156     }
157 
158 }