View Javadoc
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.artifact.deployer;
20  
21  import java.util.Collections;
22  import java.util.List;
23  
24  import org.apache.maven.artifact.Artifact;
25  import org.apache.maven.artifact.repository.ArtifactRepository;
26  import org.apache.maven.artifact.versioning.ArtifactVersion;
27  import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
28  import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException;
29  import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource;
30  import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
31  import org.apache.maven.repository.legacy.metadata.ResolutionGroup;
32  
33  /** @author Jason van Zyl */
34  public class SimpleArtifactMetadataSource implements ArtifactMetadataSource {
35      public ResolutionGroup retrieve(
36              Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories)
37              throws ArtifactMetadataRetrievalException {
38          throw new UnsupportedOperationException("Cannot retrieve metadata in this test case");
39      }
40  
41      public List<ArtifactVersion> retrieveAvailableVersions(
42              Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories)
43              throws ArtifactMetadataRetrievalException {
44          return Collections.<ArtifactVersion>singletonList(new DefaultArtifactVersion("10.1.3"));
45      }
46  
47      public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
48              Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository)
49              throws ArtifactMetadataRetrievalException {
50          return Collections.<ArtifactVersion>singletonList(new DefaultArtifactVersion("10.1.3"));
51      }
52  
53      public ResolutionGroup retrieve(MetadataResolutionRequest request) throws ArtifactMetadataRetrievalException {
54          return retrieve(request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories());
55      }
56  }