001package org.eclipse.aether.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.Map; 024 025/** 026 * A specific artifact. In a nutshell, an artifact has identifying coordinates and optionally a file that denotes its 027 * data. <em>Note:</em> Artifact instances are supposed to be immutable, e.g. any exposed mutator method returns a new 028 * artifact instance and leaves the original instance unchanged. <em>Note:</em> Implementors are strongly advised to 029 * inherit from {@link AbstractArtifact} instead of directly implementing this interface. 030 * 031 * @noimplement This interface is not intended to be implemented by clients. 032 * @noextend This interface is not intended to be extended by clients. 033 */ 034public interface Artifact 035{ 036 037 /** 038 * Gets the group identifier of this artifact, for example "org.apache.maven". 039 * 040 * @return The group identifier, never {@code null}. 041 */ 042 String getGroupId(); 043 044 /** 045 * Gets the artifact identifier of this artifact, for example "maven-model". 046 * 047 * @return The artifact identifier, never {@code null}. 048 */ 049 String getArtifactId(); 050 051 /** 052 * Gets the version of this artifact, for example "1.0-20100529-1213". Note that in case of meta versions like 053 * "1.0-SNAPSHOT", the artifact's version depends on the state of the artifact. Artifacts that have been resolved or 054 * deployed will usually have the meta version expanded. 055 * 056 * @return The version, never {@code null}. 057 */ 058 String getVersion(); 059 060 /** 061 * Sets the version of the artifact. 062 * 063 * @param version The version of this artifact, may be {@code null} or empty. 064 * @return The new artifact, never {@code null}. 065 */ 066 Artifact setVersion( String version ); 067 068 /** 069 * Gets the base version of this artifact, for example "1.0-SNAPSHOT". In contrast to the {@link #getVersion()}, the 070 * base version will always refer to the unresolved meta version. 071 * 072 * @return The base version, never {@code null}. 073 */ 074 String getBaseVersion(); 075 076 /** 077 * Determines whether this artifact uses a snapshot version. 078 * 079 * @return {@code true} if the artifact is a snapshot, {@code false} otherwise. 080 */ 081 boolean isSnapshot(); 082 083 /** 084 * Gets the classifier of this artifact, for example "sources". 085 * 086 * @return The classifier or an empty string if none, never {@code null}. 087 */ 088 String getClassifier(); 089 090 /** 091 * Gets the (file) extension of this artifact, for example "jar" or "tar.gz". 092 * 093 * @return The file extension (without leading period), never {@code null}. 094 */ 095 String getExtension(); 096 097 /** 098 * Gets the file of this artifact. Note that only resolved artifacts have a file associated with them. In general, 099 * callers must not assume any relationship between an artifact's filename and its coordinates. 100 * 101 * @return The file or {@code null} if the artifact isn't resolved. 102 */ 103 File getFile(); 104 105 /** 106 * Sets the file of the artifact. 107 * 108 * @param file The file of the artifact, may be {@code null} 109 * @return The new artifact, never {@code null}. 110 */ 111 Artifact setFile( File file ); 112 113 /** 114 * Gets the specified property. 115 * 116 * @param key The name of the property, must not be {@code null}. 117 * @param defaultValue The default value to return in case the property is not set, may be {@code null}. 118 * @return The requested property value or {@code null} if the property is not set and no default value was 119 * provided. 120 * @see ArtifactProperties 121 */ 122 String getProperty( String key, String defaultValue ); 123 124 /** 125 * Gets the properties of this artifact. Clients may use these properties to associate non-persistent values with an 126 * artifact that help later processing when the artifact gets passed around within the application. 127 * 128 * @return The (read-only) properties, never {@code null}. 129 * @see ArtifactProperties 130 */ 131 Map<String, String> getProperties(); 132 133 /** 134 * Sets the properties for the artifact. Note that these properties exist merely in memory and are not persisted 135 * when the artifact gets installed/deployed to a repository. 136 * 137 * @param properties The properties for the artifact, may be {@code null}. 138 * @return The new artifact, never {@code null}. 139 * @see ArtifactProperties 140 */ 141 Artifact setProperties( Map<String, String> properties ); 142 143}