1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.api; 20 21 import org.apache.maven.api.annotations.Experimental; 22 import org.apache.maven.api.annotations.Immutable; 23 import org.apache.maven.api.annotations.Nonnull; 24 25 /** 26 * A result of collecting, flattening and resolving {@link DependencyCoordinates}s. 27 * Dependency is the output of the <dfn>collection</dfn> process, which builds the graph of dependencies, 28 * followed by <dfn>flattening</dfn> and <dfn>resolution</dfn>. 29 * The version selection is done for each dependency during the collection phase. 30 * The flatten phase will keep only a single version per ({@code groupId}, {@code artifactId}) pair. 31 * The resolution will actually download the dependencies (or artifacts) that have been computed. 32 * 33 * @since 4.0.0 34 */ 35 @Experimental 36 @Immutable 37 public interface Dependency extends Artifact { 38 /** 39 * {@return the type of the dependency}. A dependency can be a <abbr>JAR</abbr> file, 40 * a modular-<abbr>JAR</abbr> if it is intended to be placed on the module-path, 41 * a <abbr>JAR</abbr> containing test classes, <i>etc.</i> 42 * 43 * @see DependencyCoordinates#getType() 44 */ 45 @Nonnull 46 Type getType(); 47 48 /** 49 * {@return the time at which the dependency will be used}. 50 * If may be, for example, at compile time only, at run time or at test time. 51 * 52 * @see DependencyCoordinates#getScope() 53 */ 54 @Nonnull 55 DependencyScope getScope(); 56 57 /** 58 * Returns whether the dependency is optional or mandatory. 59 * Contrarily to {@link DependencyCoordinates}, the obligation of a {@code Dependency} is always present. 60 * The value is computed during the dependencies collection phase. 61 * 62 * @return {@code true} if the dependency is optional, or {@code false} if mandatory 63 * @see DependencyCoordinates#getOptional() 64 */ 65 boolean isOptional(); 66 67 /** 68 * {@return coordinates with the same identifiers as this dependency} 69 */ 70 @Nonnull 71 @Override 72 DependencyCoordinates toCoordinates(); 73 }