View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.source.stubs;
20  
21  import org.apache.maven.artifact.handler.ArtifactHandler;
22  import org.apache.maven.artifact.versioning.VersionRange;
23  import org.apache.maven.plugin.testing.stubs.ArtifactStub;
24  
25  /**
26   * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
27   */
28  public class SourcePluginArtifactStub extends ArtifactStub {
29  
30      private String groupId;
31  
32      private String artifactId;
33  
34      private String version;
35  
36      private String type;
37  
38      private String classifier;
39  
40      private String baseVersion;
41  
42      private VersionRange versionRange;
43  
44      private ArtifactHandler handler;
45  
46      public SourcePluginArtifactStub(String groupId, String artifactId, String version, String type, String classifier) {
47          this.groupId = groupId;
48          this.artifactId = artifactId;
49          this.version = version;
50          this.type = type;
51          this.classifier = classifier;
52          versionRange = VersionRange.createFromVersion(version);
53      }
54  
55      public void setGroupId(String groupId) {
56          this.groupId = groupId;
57      }
58  
59      public String getGroupId() {
60          return groupId;
61      }
62  
63      public void setArtifactId(String artifactId) {
64          this.artifactId = artifactId;
65      }
66  
67      public String getArtifactId() {
68          return artifactId;
69      }
70  
71      public void setVersion(String version) {
72          this.version = version;
73      }
74  
75      public String getVersion() {
76          return version;
77      }
78  
79      public void setType(String packaging) {
80          this.type = packaging;
81      }
82  
83      public String getType() {
84          return type;
85      }
86  
87      public void setClassifier(String classifier) {
88          this.classifier = classifier;
89      }
90  
91      public String getClassifier() {
92          return classifier;
93      }
94  
95      public boolean hasClassifier() {
96          return classifier != null;
97      }
98  
99      public String getId() {
100         String id = groupId + ":" + artifactId + ":" + type + ":";
101 
102         if (hasClassifier()) {
103             id = id + getClassifier() + ":";
104         }
105 
106         id = id + version;
107 
108         return id;
109     }
110 
111     public VersionRange getVersionRange() {
112         return versionRange;
113     }
114 
115     public void setVersionRange(VersionRange versionRange) {
116         this.versionRange = versionRange;
117     }
118 
119     public String getBaseVersion() {
120         return baseVersion;
121     }
122 
123     public void setBaseVersion(String baseVersion) {
124         this.baseVersion = baseVersion;
125     }
126 
127     public ArtifactHandler getArtifactHandler() {
128         return handler;
129     }
130 
131     public void setArtifactHandler(ArtifactHandler handler) {
132         this.handler = handler;
133     }
134 }