View Javadoc
1   package org.apache.maven.artifact;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.Collection;
24  import java.util.List;
25  import java.util.regex.Pattern;
26  
27  import org.apache.maven.artifact.handler.ArtifactHandler;
28  import org.apache.maven.artifact.metadata.ArtifactMetadata;
29  import org.apache.maven.artifact.repository.ArtifactRepository;
30  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
31  import org.apache.maven.artifact.versioning.ArtifactVersion;
32  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
33  import org.apache.maven.artifact.versioning.VersionRange;
34  
35  /**
36   * Maven Artifact interface. Notice that it mixes artifact definition concepts (groupId, artifactId, version)
37   * with dependency information (version range, scope).
38   */
39  public interface Artifact
40      extends Comparable<Artifact>
41  {
42  
43      String RELEASE_VERSION = "RELEASE";
44  
45      String LATEST_VERSION = "LATEST";
46  
47      String SNAPSHOT_VERSION = "SNAPSHOT";
48  
49      Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" );
50  
51      // TODO: into artifactScope handler
52  
53      String SCOPE_COMPILE = "compile";
54  
55      String SCOPE_COMPILE_PLUS_RUNTIME = "compile+runtime";
56  
57      String SCOPE_TEST = "test";
58  
59      String SCOPE_RUNTIME = "runtime";
60  
61      String SCOPE_RUNTIME_PLUS_SYSTEM = "runtime+system";
62  
63      String SCOPE_PROVIDED = "provided";
64  
65      String SCOPE_SYSTEM = "system";
66  
67      String SCOPE_IMPORT = "import";   // Used to import dependencyManagement dependencies
68  
69      String getGroupId();
70  
71      String getArtifactId();
72  
73      String getVersion();
74  
75      void setVersion( String version );
76  
77      String getScope();
78  
79      String getType();
80  
81      String getClassifier();
82  
83      boolean hasClassifier();
84  
85      File getFile();
86  
87      void setFile( File destination );
88  
89      String getBaseVersion();
90  
91      void setBaseVersion( String baseVersion );
92  
93      String getId();
94  
95      String getDependencyConflictId();
96  
97      void addMetadata( ArtifactMetadata metadata );
98  
99      Collection<ArtifactMetadata> getMetadataList();
100 
101     void setRepository( ArtifactRepository remoteRepository );
102 
103     ArtifactRepository getRepository();
104 
105     void updateVersion( String version, ArtifactRepository localRepository );
106 
107     String getDownloadUrl();
108 
109     void setDownloadUrl( String downloadUrl );
110 
111     ArtifactFilter getDependencyFilter();
112 
113     void setDependencyFilter( ArtifactFilter artifactFilter );
114 
115     ArtifactHandler getArtifactHandler();
116 
117     List<String> getDependencyTrail();
118 
119     void setDependencyTrail( List<String> dependencyTrail );
120 
121     void setScope( String scope );
122 
123     VersionRange getVersionRange();
124 
125     void setVersionRange( VersionRange newRange );
126 
127     void selectVersion( String version );
128 
129     void setGroupId( String groupId );
130 
131     void setArtifactId( String artifactId );
132 
133     boolean isSnapshot();
134 
135     void setResolved( boolean resolved );
136 
137     boolean isResolved();
138 
139     void setResolvedVersion( String version );
140 
141     void setArtifactHandler( ArtifactHandler handler );
142 
143     boolean isRelease();
144 
145     void setRelease( boolean release );
146 
147     List<ArtifactVersion> getAvailableVersions();
148 
149     void setAvailableVersions( List<ArtifactVersion> versions );
150 
151     boolean isOptional();
152 
153     void setOptional( boolean optional );
154 
155     ArtifactVersion getSelectedVersion()
156         throws OverConstrainedVersionException;
157 
158     boolean isSelectedVersionKnown()
159         throws OverConstrainedVersionException;
160 
161 }