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.artifact;
20  
21  import java.io.File;
22  import java.util.Collection;
23  import java.util.List;
24  import java.util.regex.Pattern;
25  import org.apache.maven.artifact.handler.ArtifactHandler;
26  import org.apache.maven.artifact.metadata.ArtifactMetadata;
27  import org.apache.maven.artifact.repository.ArtifactRepository;
28  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
29  import org.apache.maven.artifact.versioning.ArtifactVersion;
30  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
31  import org.apache.maven.artifact.versioning.VersionRange;
32  
33  /**
34   * Maven Artifact interface. Notice that it mixes artifact definition concepts (groupId, artifactId, version)
35   * with dependency information (version range, scope).
36   */
37  public interface Artifact extends Comparable<Artifact> {
38  
39      String RELEASE_VERSION = "RELEASE";
40  
41      String LATEST_VERSION = "LATEST";
42  
43      String SNAPSHOT_VERSION = "SNAPSHOT";
44  
45      Pattern VERSION_FILE_PATTERN = Pattern.compile("^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$");
46  
47      // TODO into artifactScope handler
48  
49      String SCOPE_COMPILE = "compile";
50  
51      String SCOPE_COMPILE_PLUS_RUNTIME = "compile+runtime";
52  
53      String SCOPE_TEST = "test";
54  
55      String SCOPE_RUNTIME = "runtime";
56  
57      String SCOPE_RUNTIME_PLUS_SYSTEM = "runtime+system";
58  
59      String SCOPE_PROVIDED = "provided";
60  
61      String SCOPE_SYSTEM = "system";
62  
63      String SCOPE_IMPORT = "import"; // Used to import dependencyManagement dependencies
64  
65      String getGroupId();
66  
67      String getArtifactId();
68  
69      String getVersion();
70  
71      void setVersion(String version);
72  
73      String getScope();
74  
75      String getType();
76  
77      String getClassifier();
78  
79      boolean hasClassifier();
80  
81      File getFile();
82  
83      void setFile(File destination);
84  
85      String getBaseVersion();
86  
87      void setBaseVersion(String baseVersion);
88  
89      String getId();
90  
91      String getDependencyConflictId();
92  
93      void addMetadata(ArtifactMetadata metadata);
94  
95      Collection<ArtifactMetadata> getMetadataList();
96  
97      void setRepository(ArtifactRepository remoteRepository);
98  
99      ArtifactRepository getRepository();
100 
101     void updateVersion(String version, ArtifactRepository localRepository);
102 
103     String getDownloadUrl();
104 
105     void setDownloadUrl(String downloadUrl);
106 
107     ArtifactFilter getDependencyFilter();
108 
109     void setDependencyFilter(ArtifactFilter artifactFilter);
110 
111     ArtifactHandler getArtifactHandler();
112 
113     List<String> getDependencyTrail();
114 
115     void setDependencyTrail(List<String> dependencyTrail);
116 
117     void setScope(String scope);
118 
119     VersionRange getVersionRange();
120 
121     void setVersionRange(VersionRange newRange);
122 
123     void selectVersion(String version);
124 
125     void setGroupId(String groupId);
126 
127     void setArtifactId(String artifactId);
128 
129     boolean isSnapshot();
130 
131     void setResolved(boolean resolved);
132 
133     boolean isResolved();
134 
135     void setResolvedVersion(String version);
136 
137     void setArtifactHandler(ArtifactHandler handler);
138 
139     boolean isRelease();
140 
141     void setRelease(boolean release);
142 
143     List<ArtifactVersion> getAvailableVersions();
144 
145     void setAvailableVersions(List<ArtifactVersion> versions);
146 
147     boolean isOptional();
148 
149     void setOptional(boolean optional);
150 
151     ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException;
152 
153     boolean isSelectedVersionKnown() throws OverConstrainedVersionException;
154 }