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