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