001package org.apache.maven.artifact;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.File;
023import java.util.Collection;
024import java.util.List;
025import java.util.regex.Pattern;
026
027import org.apache.maven.artifact.handler.ArtifactHandler;
028import org.apache.maven.artifact.metadata.ArtifactMetadata;
029import org.apache.maven.artifact.repository.ArtifactRepository;
030import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
031import org.apache.maven.artifact.versioning.ArtifactVersion;
032import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
033import org.apache.maven.artifact.versioning.VersionRange;
034
035/**
036 * Maven Artifact interface. Notice that it mixes artifact definition concepts (groupId, artifactId, version)
037 * with dependency information (version range, scope).
038 */
039public interface Artifact
040    extends Comparable<Artifact>
041{
042
043    String RELEASE_VERSION = "RELEASE";
044
045    String LATEST_VERSION = "LATEST";
046
047    String SNAPSHOT_VERSION = "SNAPSHOT";
048
049    Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" );
050
051    // TODO: into artifactScope handler
052
053    String SCOPE_COMPILE = "compile";
054
055    String SCOPE_COMPILE_PLUS_RUNTIME = "compile+runtime";
056
057    String SCOPE_TEST = "test";
058
059    String SCOPE_RUNTIME = "runtime";
060
061    String SCOPE_RUNTIME_PLUS_SYSTEM = "runtime+system";
062
063    String SCOPE_PROVIDED = "provided";
064
065    String SCOPE_SYSTEM = "system";
066
067    String SCOPE_IMPORT = "import";   // Used to import dependencyManagement dependencies
068
069    String getGroupId();
070
071    String getArtifactId();
072
073    String getVersion();
074
075    void setVersion( String version );
076
077    String getScope();
078
079    String getType();
080
081    String getClassifier();
082
083    boolean hasClassifier();
084
085    File getFile();
086
087    void setFile( File destination );
088
089    String getBaseVersion();
090
091    void setBaseVersion( String baseVersion );
092
093    String getId();
094
095    String getDependencyConflictId();
096
097    void addMetadata( ArtifactMetadata metadata );
098
099    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}