~ubuntu-branches/ubuntu/trusty/ivy/trusty

« back to all changes in this revision

Viewing changes to src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2009-03-06 22:04:56 UTC
  • Revision ID: james.westby@ubuntu.com-20090306220456-5v37luqiuqda8ewp
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
8
 *
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
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.
 
16
 *
 
17
 */
 
18
package org.apache.ivy.plugins.resolver;
 
19
 
 
20
import java.io.File;
 
21
import java.io.IOException;
 
22
import java.text.ParseException;
 
23
import java.util.Map;
 
24
 
 
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;
 
40
 
 
41
/**
 
42
 *
 
43
 */
 
44
public interface DependencyResolver {
 
45
    String getName();
 
46
 
 
47
    /**
 
48
     * Should only be used by configurator
 
49
     * 
 
50
     * @param name
 
51
     *            the new name of the resolver
 
52
     */
 
53
    void setName(String name);
 
54
 
 
55
    /**
 
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 ##)
 
60
     * 
 
61
     * @throws ParseException
 
62
     */
 
63
    ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
 
64
            throws ParseException;
 
65
    
 
66
    /**
 
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.
 
69
     * 
 
70
     * @param dd the dependency descriptor
 
71
     * @param data the resolve data
 
72
     * @return the module descriptor, or <tt>null</tt>
 
73
     */
 
74
    ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data);
 
75
 
 
76
    /**
 
77
     * Download artifacts with specified DownloadOptions.
 
78
     * <p>
 
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.
 
82
     * </p>
 
83
     * <p>
 
84
     * The returned DownloadReport is never <code>null</code>, and always contain an
 
85
     * {@link ArtifactDownloadReport} for each requested Artifact.
 
86
     * </p>
 
87
     * 
 
88
     * @param artifacts
 
89
     *            an array of artifacts to download. Must not be <code>null</code>.
 
90
     * @param options
 
91
     *            options to apply for this download. Must not be <code>null</code>.
 
92
     * @return a DownloadReport with details about each Artifact download.
 
93
     */
 
94
    DownloadReport download(Artifact[] artifacts, DownloadOptions options);
 
95
    
 
96
    /**
 
97
     * Download an artifact according to the given DownloadOptions.
 
98
     * <p>
 
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.
 
102
     * </p>
 
103
     * 
 
104
     * @param artifact
 
105
     *            the location of the artifact to download. Must not be <code>null</code>.
 
106
     * @param options
 
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>.
 
109
     */
 
110
    ArtifactDownloadReport download(ArtifactOrigin artifact, DownloadOptions options);
 
111
    
 
112
 
 
113
    /**
 
114
     * Returns <code>true</code> if the given artifact can be located by this resolver and
 
115
     * actually exist.
 
116
     * 
 
117
     * @param artifact
 
118
     *            the artifact which should be tested.
 
119
     * @return <code>true</code> if the given artifact can be located by this resolver and
 
120
     *         actually exist.
 
121
     */
 
122
    boolean exists(Artifact artifact);
 
123
 
 
124
    /**
 
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.
 
127
     * 
 
128
     * @param artifact
 
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
 
131
     *         or doesn't exist.
 
132
     */
 
133
    ArtifactOrigin locate(Artifact artifact);
 
134
 
 
135
    void publish(Artifact artifact, File src, boolean overwrite) throws IOException;
 
136
    
 
137
    void beginPublishTransaction(ModuleRevisionId module, boolean overwrite) throws IOException;
 
138
    void abortPublishTransaction() throws IOException;
 
139
    void commitPublishTransaction() throws IOException;
 
140
 
 
141
    /**
 
142
     * Reports last resolve failure as Messages
 
143
     */
 
144
    void reportFailure();
 
145
 
 
146
    /**
 
147
     * Reports last artifact download failure as Messages
 
148
     * 
 
149
     * @param art
 
150
     */
 
151
    void reportFailure(Artifact art);
 
152
 
 
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.
 
157
 
 
158
    /**
 
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.
 
163
     * <p>
 
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()}.
 
167
     * </p>
 
168
     */
 
169
    String[] listTokenValues(String token, Map otherTokenValues);
 
170
    
 
171
    Map[] listTokenValues(String[] tokens, Map criteria);
 
172
 
 
173
    OrganisationEntry[] listOrganisations();
 
174
 
 
175
    ModuleEntry[] listModules(OrganisationEntry org);
 
176
 
 
177
    RevisionEntry[] listRevisions(ModuleEntry module);
 
178
    
 
179
    /**
 
180
     * Returns the namespace associated with this resolver.
 
181
     * @return the namespace associated with this resolver.
 
182
     */
 
183
    Namespace getNamespace();
 
184
    
 
185
    void dumpSettings();
 
186
    
 
187
    void setSettings(ResolverSettings settings);
 
188
 
 
189
    /**
 
190
     * Returns the {@link RepositoryCacheManager} used to manage the repository cache associated
 
191
     * with this dependency resolver.
 
192
     * 
 
193
     * @return the {@link RepositoryCacheManager} used to manage the repository cache associated
 
194
     *         with this dependency resolver.
 
195
     */
 
196
    RepositoryCacheManager getRepositoryCacheManager();
 
197
}