2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.ivy.plugins.resolver;
21
import java.io.IOException;
22
import java.text.ParseException;
25
import org.apache.ivy.core.cache.ArtifactOrigin;
26
import org.apache.ivy.core.cache.RepositoryCacheManager;
27
import org.apache.ivy.core.module.descriptor.Artifact;
28
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
29
import org.apache.ivy.core.module.id.ModuleRevisionId;
30
import org.apache.ivy.core.report.ArtifactDownloadReport;
31
import org.apache.ivy.core.report.DownloadReport;
32
import org.apache.ivy.core.resolve.DownloadOptions;
33
import org.apache.ivy.core.resolve.ResolveData;
34
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
35
import org.apache.ivy.core.search.ModuleEntry;
36
import org.apache.ivy.core.search.OrganisationEntry;
37
import org.apache.ivy.core.search.RevisionEntry;
38
import org.apache.ivy.plugins.namespace.Namespace;
39
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
44
public interface DependencyResolver {
48
* Should only be used by configurator
51
* the new name of the resolver
53
void setName(String name);
56
* Resolve a module by id, getting its module descriptor and resolving the revision if it's a
57
* latest one (i.e. a revision uniquely identifying the revision of a module in the current
58
* environment - If this revision is not able to identify uniquelely the revision of the module
59
* outside of the current environment, then the resolved revision must begin by ##)
61
* @throws ParseException
63
ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
64
throws ParseException;
67
* Finds the module descriptor for the specified <tt>DependencyDescriptor</tt>.
68
* If this resolver can't find the module descriptor, <tt>null</tt> is returned.
70
* @param dd the dependency descriptor
71
* @param data the resolve data
72
* @return the module descriptor, or <tt>null</tt>
74
ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data);
77
* Download artifacts with specified DownloadOptions.
79
* The resolver will always make a best effort, and do not stop when an artifact is not
80
* available. It rather continue to attempt to download other requested artifacts, and report
81
* what has been done in the returned DownloadReport.
84
* The returned DownloadReport is never <code>null</code>, and always contain an
85
* {@link ArtifactDownloadReport} for each requested Artifact.
89
* an array of artifacts to download. Must not be <code>null</code>.
91
* options to apply for this download. Must not be <code>null</code>.
92
* @return a DownloadReport with details about each Artifact download.
94
DownloadReport download(Artifact[] artifacts, DownloadOptions options);
97
* Download an artifact according to the given DownloadOptions.
99
* This methods is an alternative to {@link #download(Artifact[], DownloadOptions)}, which
100
* locates and downloads a set of artifacts. This method uses an {@link ArtifactOrigin}, and as
101
* such is only used to materialize an already located Artifact.
105
* the location of the artifact to download. Must not be <code>null</code>.
107
* options to apply for this download. Must not be <code>null</code>.
108
* @return a report detailing how the download has gone, is never <code>null</code>.
110
ArtifactDownloadReport download(ArtifactOrigin artifact, DownloadOptions options);
114
* Returns <code>true</code> if the given artifact can be located by this resolver and
118
* the artifact which should be tested.
119
* @return <code>true</code> if the given artifact can be located by this resolver and
122
boolean exists(Artifact artifact);
125
* Locates the given artifact and returns its location if it can be located by this resolver and
126
* if it actually exists, or <code>null</code> in other cases.
129
* the artifact which should be located
130
* @return the artifact location, or <code>null</code> if it can't be located by this resolver
133
ArtifactOrigin locate(Artifact artifact);
135
void publish(Artifact artifact, File src, boolean overwrite) throws IOException;
137
void beginPublishTransaction(ModuleRevisionId module, boolean overwrite) throws IOException;
138
void abortPublishTransaction() throws IOException;
139
void commitPublishTransaction() throws IOException;
142
* Reports last resolve failure as Messages
144
void reportFailure();
147
* Reports last artifact download failure as Messages
151
void reportFailure(Artifact art);
153
// listing methods, enable to know what is available from this resolver
154
// the listing methods must only list entries directly
155
// available from them, no recursion is needed as long as sub resolvers
156
// are registered in ivy too.
159
* List all the values the given token can take if other tokens are set as described in the
160
* otherTokenValues map. For instance, if token = "revision" and the map contains
161
* "organisation"->"foo" "module"->"bar" The results will be the list of revisions of the module
162
* bar from the org foo.
164
* Note that listing does not take into account namespaces, and return raw
165
* information without any namespace transformation. The caller is responsible for calling
166
* namespace transformation with the Namespace returned by {@link #getNamespace()}.
169
String[] listTokenValues(String token, Map otherTokenValues);
171
Map[] listTokenValues(String[] tokens, Map criteria);
173
OrganisationEntry[] listOrganisations();
175
ModuleEntry[] listModules(OrganisationEntry org);
177
RevisionEntry[] listRevisions(ModuleEntry module);
180
* Returns the namespace associated with this resolver.
181
* @return the namespace associated with this resolver.
183
Namespace getNamespace();
187
void setSettings(ResolverSettings settings);
190
* Returns the {@link RepositoryCacheManager} used to manage the repository cache associated
191
* with this dependency resolver.
193
* @return the {@link RepositoryCacheManager} used to manage the repository cache associated
194
* with this dependency resolver.
196
RepositoryCacheManager getRepositoryCacheManager();