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.services; 20 21 import java.nio.file.Path; 22 import java.util.List; 23 import java.util.Map; 24 import java.util.Optional; 25 26 import org.apache.maven.api.Dependency; 27 import org.apache.maven.api.JavaPathType; 28 import org.apache.maven.api.Node; 29 import org.apache.maven.api.PathType; 30 import org.apache.maven.api.annotations.Experimental; 31 import org.apache.maven.api.annotations.Nonnull; 32 33 @Experimental 34 public interface DependencyResolverResult extends DependencyCollectorResult { 35 36 /** 37 * The ordered list of the flattened dependency nodes. 38 * 39 * @return the ordered list of the flattened dependency nodes 40 */ 41 @Nonnull 42 List<Node> getNodes(); 43 44 /** 45 * Returns the file paths of all dependencies, regardless on which tool option those paths should be placed. 46 * The returned list may contain a mix of Java class-path, Java module-path, and other types of path elements. 47 * This collection has the same content than {@code getDependencies.values()} except that it does not contain 48 * null elements. 49 * 50 * @return the paths of all dependencies 51 */ 52 @Nonnull 53 List<Path> getPaths(); 54 55 /** 56 * Returns the file paths of all dependencies, dispatched according the tool options where to place them. 57 * The {@link PathType} keys identify, for example, {@code --class-path} or {@code --module-path} options. 58 * In the case of Java tools, the map may also contain {@code --patch-module} options, which are 59 * {@linkplain org.apache.maven.api.JavaPathType#patchModule(String) handled in a special way}. 60 * 61 * <h4>Design note</h4> 62 * All types of path are determined together because they are sometime mutually exclusive. 63 * For example, an artifact of type {@value org.apache.maven.api.Type#JAR} can be placed 64 * either on the class-path or on the module-path. The project needs to make a choice 65 * (possibly using heuristic rules), then to add the dependency in only one of the options 66 * identified by {@link PathType}. 67 * 68 * @return file paths to place on the different tool options 69 */ 70 @Nonnull 71 Map<PathType, List<Path>> getDispatchedPaths(); 72 73 /** 74 * {@return all dependencies associated to their paths}. 75 * Some dependencies may be associated to a null value if there is no path available. 76 */ 77 @Nonnull 78 Map<Dependency, Path> getDependencies(); 79 80 /** 81 * If the module-path contains at least one filename-based auto-module, prepares a warning message. 82 * The module path is the collection of dependencies associated to {@link JavaPathType#MODULES}. 83 * It is caller's responsibility to send the message to a logger. 84 * 85 * @return warning message if at least one filename-based auto-module was found 86 */ 87 Optional<String> warningForFilenameBasedAutomodules(); 88 }