View Javadoc

1   package org.sonatype.aether.artifact;
2   
3   /*******************************************************************************
4    * Copyright (c) 2010-2011 Sonatype, Inc.
5    * All rights reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    *   http://www.eclipse.org/legal/epl-v10.html
9    *******************************************************************************/
10  
11  import java.io.File;
12  import java.util.Map;
13  
14  /**
15   * A specific artifact. <em>Note:</em> Artifact instances are supposed to be immutable, e.g. any exposed mutator method
16   * returns a new artifact instance and leaves the original instance unchanged. Implementors are strongly advised to obey
17   * this contract.
18   * 
19   * @author Benjamin Bentmann
20   */
21  public interface Artifact
22  {
23  
24      /**
25       * Gets the group identifier of this artifact, for example "org.apache.maven".
26       * 
27       * @return The group identifier, never {@code null}.
28       */
29      String getGroupId();
30  
31      /**
32       * Gets the artifact identifier of this artifact, for example "maven-model".
33       * 
34       * @return The artifact identifier, never {@code null}.
35       */
36      String getArtifactId();
37  
38      /**
39       * Gets the version of this artifact, for example "1.0-20100529-1213". Note that in case of meta versions like
40       * "1.0-SNAPSHOT", the artifact's version depends on the state of the artifact. Artifacts that have been resolved or
41       * deployed will have the meta version expanded.
42       * 
43       * @return The version, never {@code null}.
44       */
45      String getVersion();
46  
47      /**
48       * Sets the version of this artifact.
49       * 
50       * @param version The version of this artifact, may be {@code null} or empty.
51       * @return The new artifact, never {@code null}.
52       */
53      Artifact setVersion( String version );
54  
55      /**
56       * Gets the base version of this artifact, for example "1.0-SNAPSHOT". In contrast to the {@link #getVersion()}, the
57       * base version will always refer to the unresolved meta version.
58       * 
59       * @return The base version, never {@code null}.
60       */
61      String getBaseVersion();
62  
63      /**
64       * Determines whether this artifact uses a snapshot version.
65       * 
66       * @return {@code true} if the artifact is a snapshot, {@code false} otherwise.
67       */
68      boolean isSnapshot();
69  
70      /**
71       * Gets the classifier of this artifact, for example "sources".
72       * 
73       * @return The classifier or an empty string if none, never {@code null}.
74       */
75      String getClassifier();
76  
77      /**
78       * Gets the (file) extension of this artifact, for example "jar".
79       * 
80       * @return The file extension, never {@code null}.
81       */
82      String getExtension();
83  
84      /**
85       * Gets the file of this artifact. Note that only resolved artifacts have a file associated with them.
86       * 
87       * @return The file or {@code null} if the artifact isn't resolved.
88       */
89      File getFile();
90  
91      /**
92       * Sets the file of the artifact.
93       * 
94       * @param file The file of the artifact, may be {@code null}
95       * @return The new artifact, never {@code null}.
96       */
97      Artifact setFile( File file );
98  
99      /**
100      * Gets the specified property.
101      * 
102      * @param key The name of the property, must not be {@code null}.
103      * @param defaultValue The default value to return in case the property is not set, may be {@code null}.
104      */
105     String getProperty( String key, String defaultValue );
106 
107     /**
108      * Gets the properties of this artifact. While the exact set of available properties is undefined, the following
109      * properties are considered to be common:
110      * <dl>
111      * <dt>type</dt>
112      * <dd>A high-level characterization of the artifact, e.g. "maven-plugin" or "test-jar".</dd>
113      * <dt>language</dt>
114      * <dd>The programming language this artifact is relevant for, e.g. "java" or "none".</dd>
115      * <dt>includesDependencies</dt>
116      * <dd>A boolean flag indicating whether the artifact presents some kind of bundle that physically includes its
117      * dependencies, e.g. a fat WAR.</dd>
118      * <dt>constitutesBuildPath</dt>
119      * <dd>A boolean flag indicating whether the artifact is meant to be used for the compile/runtime/test build path of
120      * a consumer project.</dd>
121      * <dt>localPath</dt>
122      * <dd>The (expected) path to the artifact on the local filesystem. An artifact which has this property set is
123      * assumed to be not present in any regular repository and likewise has no artifact descriptor.</dd>
124      * </dl>
125      * 
126      * @return The (read-only) properties, never {@code null}.
127      */
128     Map<String, String> getProperties();
129 
130     /**
131      * Sets the properties for the artifact.
132      * 
133      * @param properties The properties for the artifact, may be {@code null}.
134      * @return The new artifact, never {@code null}.
135      */
136     Artifact setProperties( Map<String, String> properties );
137 
138 }