1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.resolution
;
13 import org
.eclipse
.aether
.RepositorySystem
;
14 import org
.eclipse
.aether
.RepositorySystemSession
;
15 import org
.eclipse
.aether
.RequestTrace
;
16 import org
.eclipse
.aether
.artifact
.Artifact
;
17 import org
.eclipse
.aether
.collection
.CollectRequest
;
18 import org
.eclipse
.aether
.graph
.DependencyFilter
;
19 import org
.eclipse
.aether
.graph
.DependencyNode
;
22 * A request to resolve transitive dependencies. This request can either be supplied with a {@link CollectRequest} to
23 * calculate the transitive dependencies or with an already resolved dependency graph.
25 * @see RepositorySystem#resolveDependencies(RepositorySystemSession, DependencyRequest)
26 * @see Artifact#getFile()
28 public final class DependencyRequest
31 private DependencyNode root
;
33 private CollectRequest collectRequest
;
35 private DependencyFilter filter
;
37 private RequestTrace trace
;
40 * Creates an uninitialized request. Note that either {@link #setRoot(DependencyNode)} or
41 * {@link #setCollectRequest(CollectRequest)} must eventually be called to create a valid request.
43 public DependencyRequest()
45 // enables default constructor
49 * Creates a request for the specified dependency graph and with the given resolution filter.
51 * @param node The root node of the dependency graph whose artifacts should be resolved, may be {@code null}.
52 * @param filter The resolution filter to use, may be {@code null}.
54 public DependencyRequest( DependencyNode node
, DependencyFilter filter
)
61 * Creates a request for the specified collect request and with the given resolution filter.
63 * @param request The collect request used to calculate the dependency graph whose artifacts should be resolved, may
65 * @param filter The resolution filter to use, may be {@code null}.
67 public DependencyRequest( CollectRequest request
, DependencyFilter filter
)
69 setCollectRequest( request
);
74 * Gets the root node of the dependency graph whose artifacts should be resolved.
76 * @return The root node of the dependency graph or {@code null} if none.
78 public DependencyNode
getRoot()
84 * Sets the root node of the dependency graph whose artifacts should be resolved. When this request is processed,
85 * the nodes of the given dependency graph will be updated to refer to the resolved artifacts. Eventually, either
86 * {@link #setRoot(DependencyNode)} or {@link #setCollectRequest(CollectRequest)} must be called to create a valid
89 * @param root The root node of the dependency graph, may be {@code null}.
90 * @return This request for chaining, never {@code null}.
92 public DependencyRequest
setRoot( DependencyNode root
)
99 * Gets the collect request used to calculate the dependency graph whose artifacts should be resolved.
101 * @return The collect request or {@code null} if none.
103 public CollectRequest
getCollectRequest()
105 return collectRequest
;
109 * Sets the collect request used to calculate the dependency graph whose artifacts should be resolved. Eventually,
110 * either {@link #setRoot(DependencyNode)} or {@link #setCollectRequest(CollectRequest)} must be called to create a
111 * valid request. If this request is supplied with a dependency node via {@link #setRoot(DependencyNode)}, the
112 * collect request is ignored.
114 * @param collectRequest The collect request, may be {@code null}.
115 * @return This request for chaining, never {@code null}.
117 public DependencyRequest
setCollectRequest( CollectRequest collectRequest
)
119 this.collectRequest
= collectRequest
;
124 * Gets the resolution filter used to select which artifacts of the dependency graph should be resolved.
126 * @return The resolution filter or {@code null} to resolve all artifacts of the dependency graph.
128 public DependencyFilter
getFilter()
134 * Sets the resolution filter used to select which artifacts of the dependency graph should be resolved. For
135 * example, use this filter to restrict resolution to dependencies of a certain scope.
137 * @param filter The resolution filter, may be {@code null} to resolve all artifacts of the dependency graph.
138 * @return This request for chaining, never {@code null}.
140 public DependencyRequest
setFilter( DependencyFilter filter
)
142 this.filter
= filter
;
147 * Gets the trace information that describes the higher level request/operation in which this request is issued.
149 * @return The trace information about the higher level operation or {@code null} if none.
151 public RequestTrace
getTrace()
157 * Sets the trace information that describes the higher level request/operation in which this request is issued.
159 * @param trace The trace information about the higher level operation, may be {@code null}.
160 * @return This request for chaining, never {@code null}.
162 public DependencyRequest
setTrace( RequestTrace trace
)
169 public String
toString()
173 return String
.valueOf( root
);
175 return String
.valueOf( collectRequest
);