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 import org.apache.maven.api.annotations.Nullable; 25 import org.apache.maven.api.model.Dependency; 26 27 /** 28 * A dependency's {@code Type} is uniquely identified by a {@code String}, 29 * and semantically represents a known <i>kind</i> of dependency. 30 * <p> 31 * It provides information about the file type (or extension) of the associated artifact, 32 * its default classifier, and how the artifact will be used in the build when creating 33 * classpaths. 34 * <p> 35 * For example, the type {@code java-source} has a {@code jar} extension and a 36 * {@code sources} classifier. The artifact and its dependencies should be added 37 * to the classpath. 38 * 39 * @since 4.0.0 40 */ 41 @Experimental 42 @Immutable 43 public interface Type { 44 45 String LANGUAGE_NONE = "none"; 46 String LANGUAGE_JAVA = "java"; 47 48 /** 49 * Returns the dependency type id. 50 * The id uniquely identifies this <i>dependency type</i>. 51 * 52 * @return the id of this type, never {@code null}. 53 */ 54 @Nonnull 55 String getId(); 56 57 /** 58 * Returns the dependency type language. 59 * 60 * @return the language of this type, never {@code null}. 61 */ 62 String getLanguage(); 63 64 /** 65 * Get the file extension of artifacts of this type. 66 * 67 * @return the file extension, never {@code null}. 68 */ 69 @Nonnull 70 String getExtension(); 71 72 /** 73 * Get the default classifier associated to the dependency type. 74 * The default classifier can be overridden when specifying 75 * the {@link Dependency#getClassifier()}. 76 * 77 * @return the default classifier, or {@code null}. 78 */ 79 @Nullable 80 String getClassifier(); 81 82 /** 83 * Specifies if the artifact contains java classes and should be 84 * added to the classpath. 85 * 86 * @return if the artifact should be added to the class path 87 */ 88 default boolean isAddedToClassPath() { 89 return getDependencyProperties().checkFlag(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT); 90 } 91 92 /** 93 * Specifies if the artifact already embeds its own dependencies. 94 * This is the case for JEE packages or similar artifacts such as 95 * WARs, EARs, etc. 96 * 97 * @return if the artifact's dependencies are included in the artifact 98 */ 99 default boolean isIncludesDependencies() { 100 return getDependencyProperties().checkFlag(DependencyProperties.FLAG_INCLUDES_DEPENDENCIES); 101 } 102 103 /** 104 * Gets the default properties associated with this dependency type. 105 * 106 * @return the default properties, never {@code null}. 107 */ 108 @Nonnull 109 DependencyProperties getDependencyProperties(); 110 }