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.plugin.internal;
20
21 import java.util.List;
22
23 import org.apache.maven.model.Plugin;
24 import org.apache.maven.plugin.PluginResolutionException;
25 import org.eclipse.aether.RepositorySystemSession;
26 import org.eclipse.aether.artifact.Artifact;
27 import org.eclipse.aether.graph.DependencyFilter;
28 import org.eclipse.aether.graph.DependencyNode;
29 import org.eclipse.aether.repository.RemoteRepository;
30 import org.eclipse.aether.resolution.DependencyResult;
31
32 /**
33 * Assists in resolving the dependencies of a plugin. <strong>Warning:</strong> This is an internal utility interface
34 * that is only public for technical reasons, it is not part of the public API. In particular, this interface can be
35 * changed or deleted without prior notice.
36 *
37 * @since 3.0
38 * @author Benjamin Bentmann
39 */
40 public interface PluginDependenciesResolver {
41
42 /**
43 * Resolves the main artifact of the specified plugin.
44 *
45 * @param plugin The plugin for which to resolve the main artifact, must not be {@code null}.
46 * @param repositories The plugin repositories to use for resolving the plugin's main artifact, must not be {@code
47 * null}.
48 * @param session The repository session to use for resolving the plugin's main artifact, must not be {@code null}.
49 * @return The resolved plugin artifact, never {@code null}.
50 * @throws PluginResolutionException If the plugin artifact could not be resolved.
51 */
52 Artifact resolve(Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session)
53 throws PluginResolutionException;
54
55 /**
56 * Resolves the runtime dependencies of the specified plugin.
57 *
58 * @param plugin The plugin for which to resolve the dependencies, must not be {@code null}.
59 * @param pluginArtifact The plugin's main artifact, may be {@code null}.
60 * @param dependencyFilter A filter to exclude artifacts from resolution (but not collection), may be {@code null}.
61 * @param repositories The plugin repositories to use for resolving the plugin artifacts, must not be {@code null}.
62 * @param session The repository session to use for resolving the plugin artifacts, must not be {@code null}.
63 * @return The dependency tree denoting the resolved plugin class path, never {@code null}.
64 * @throws PluginResolutionException If any dependency could not be resolved.
65 * @deprecated This method should be avoided, as it requires manual flattening; use {@link #resolvePluginAndFlatten(Plugin, Artifact, DependencyFilter, List, RepositorySystemSession)} instead to let Resolver handle it.
66 */
67 @Deprecated
68 DependencyNode resolve(
69 Plugin plugin,
70 Artifact pluginArtifact,
71 DependencyFilter dependencyFilter,
72 List<RemoteRepository> repositories,
73 RepositorySystemSession session)
74 throws PluginResolutionException;
75
76 /**
77 * Resolves the runtime dependencies of the specified core extension (as {@link Plugin} as GAV carrier).
78 *
79 * @param plugin The plugin for which to resolve the dependencies, must not be {@code null}.
80 * @param dependencyFilter A filter to exclude artifacts from resolution (but not collection), may be {@code null}.
81 * @param repositories The plugin repositories to use for resolving the plugin artifacts, must not be {@code null}.
82 * @param session The repository session to use for resolving the plugin artifacts, must not be {@code null}.
83 * @return The dependency resolution result having the resolved extension class path but also the tree, never {@code null}.
84 * @throws PluginResolutionException If any dependency could not be resolved.
85 * @since 3.10.0
86 */
87 DependencyResult resolveCoreExtensionAndFlatten(
88 Plugin plugin,
89 DependencyFilter dependencyFilter,
90 List<RemoteRepository> repositories,
91 RepositorySystemSession session)
92 throws PluginResolutionException;
93
94 /**
95 * Resolves the runtime dependencies of the specified plugin.
96 *
97 * @param plugin The plugin for which to resolve the dependencies, must not be {@code null}.
98 * @param pluginArtifact The plugin's main artifact, may be {@code null}.
99 * @param dependencyFilter A filter to exclude artifacts from resolution (but not collection), may be {@code null}.
100 * @param repositories The plugin repositories to use for resolving the plugin artifacts, must not be {@code null}.
101 * @param session The repository session to use for resolving the plugin artifacts, must not be {@code null}.
102 * @return The dependency resolution result having the resolved plugin class path but also the tree, never {@code null}.
103 * @throws PluginResolutionException If any dependency could not be resolved.
104 * @since 3.10.0
105 */
106 DependencyResult resolvePluginAndFlatten(
107 Plugin plugin,
108 Artifact pluginArtifact,
109 DependencyFilter dependencyFilter,
110 List<RemoteRepository> repositories,
111 RepositorySystemSession session)
112 throws PluginResolutionException;
113 }