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 org.apache.maven.artifact.handler.ArtifactHandler;
23  import org.apache.maven.artifact.metadata.ArtifactMetadata;
24  import org.apache.maven.artifact.repository.ArtifactRepository;
25  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
26  import org.apache.maven.artifact.versioning.ArtifactVersion;
27  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
28  import org.apache.maven.artifact.versioning.VersionRange;
29  
30  import java.io.File;
31  import java.util.Collection;
32  import java.util.List;
33  import java.util.regex.Pattern;
34  
35  /**
36   * Description of an artifact.
37   *
38   * @todo do we really need an interface here?
39   * @todo get rid of the multiple states we can have (project, parent, etc artifacts, file == null, snapshot, etc) - construct subclasses and use accordingly?
40   */
41  public interface Artifact
42      extends Comparable<Artifact>
43  {
44      String LATEST_VERSION = "LATEST";
45  
46      String SNAPSHOT_VERSION = "SNAPSHOT";
47  
48      Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" );
49  
50      // TODO: into scope handler
51      String SCOPE_COMPILE = "compile";
52  
53      String SCOPE_TEST = "test";
54  
55      String SCOPE_RUNTIME = "runtime";
56  
57      String SCOPE_PROVIDED = "provided";
58  
59      String SCOPE_SYSTEM = "system";
60  
61      String SCOPE_IMPORT = "import";   // Used to import dependencyManagement dependencies
62  
63      String RELEASE_VERSION = "RELEASE";
64  
65      String getGroupId();
66  
67      String getArtifactId();
68  
69      String getVersion();
70  
71      void setVersion( String version );
72  
73      /**
74       * Get the scope of the artifact. If the artifact is a standalone rather than a dependency, it's scope will be
75       * <code>null</code>. The scope may not be the same as it was declared on the original dependency, as this is the
76       * result of combining it with the main project scope.
77       *
78       * @return the scope
79       */
80      String getScope();
81  
82      String getType();
83  
84      String getClassifier();
85  
86      // only providing this since classifier is *very* optional...
87      boolean hasClassifier();
88  
89      File getFile();
90  
91      void setFile( File destination );
92  
93      String getBaseVersion();
94  
95      /**
96       * @todo would like to get rid of this - or at least only have one. Base version should be immutable.
97       */
98      void setBaseVersion( String baseVersion );
99  
100     // ----------------------------------------------------------------------
101 
102     String getId();
103 
104     String getDependencyConflictId();
105 
106     void addMetadata( ArtifactMetadata metadata );
107     
108     ArtifactMetadata getMetadata( Class<?> metadataClass );
109 
110     Collection<ArtifactMetadata> getMetadataList();
111 
112     void setRepository( ArtifactRepository remoteRepository );
113 
114     ArtifactRepository getRepository();
115 
116     void updateVersion( String version, ArtifactRepository localRepository );
117 
118     String getDownloadUrl();
119 
120     void setDownloadUrl( String downloadUrl );
121 
122     ArtifactFilter getDependencyFilter();
123 
124     void setDependencyFilter( ArtifactFilter artifactFilter );
125 
126     ArtifactHandler getArtifactHandler();
127 
128     /**
129      * @return {@link List} &lt; {@link String} > with artifact ids
130      */
131     List<String> getDependencyTrail();
132 
133     /**
134      * @param dependencyTrail {@link List} &lt; {@link String} > with artifact ids
135      */
136     void setDependencyTrail( List<String> dependencyTrail );
137 
138     void setScope( String scope );
139 
140     VersionRange getVersionRange();
141 
142     void setVersionRange( VersionRange newRange );
143 
144     void selectVersion( String version );
145 
146     void setGroupId( String groupId );
147 
148     void setArtifactId( String artifactId );
149 
150     boolean isSnapshot();
151 
152     void setResolved( boolean resolved );
153 
154     boolean isResolved();
155 
156     void setResolvedVersion( String version );
157 
158     /**
159      * @todo remove, a quick hack for the lifecycle executor
160      */
161     void setArtifactHandler( ArtifactHandler handler );
162 
163     boolean isRelease();
164 
165     void setRelease( boolean release );
166 
167     List<ArtifactVersion> getAvailableVersions();
168 
169     void setAvailableVersions( List<ArtifactVersion> versions );
170 
171     boolean isOptional();
172     
173     void setOptional( boolean optional );
174 
175     ArtifactVersion getSelectedVersion()
176         throws OverConstrainedVersionException;
177 
178     boolean isSelectedVersionKnown()
179         throws OverConstrainedVersionException;
180 }