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