1 package org.apache.archiva.metadata.repository.storage.maven2;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
24 import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
25 import org.apache.maven.model.Repository;
26 import org.apache.maven.model.building.FileModelSource;
27 import org.apache.maven.model.building.ModelSource;
28 import org.apache.maven.model.resolution.InvalidRepositoryException;
29 import org.apache.maven.model.resolution.ModelResolver;
30 import org.apache.maven.model.resolution.UnresolvableModelException;
32 public class RepositoryModelResolver
33 implements ModelResolver
37 private RepositoryPathTranslator pathTranslator;
39 public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator )
41 this.basedir = basedir;
43 this.pathTranslator = pathTranslator;
46 public ModelSource resolveModel( String groupId, String artifactId, String version )
47 throws UnresolvableModelException
49 String filename = artifactId + "-" + version + ".pom";
50 // TODO: we need to convert 1.0-20091120.112233-1 type paths to baseVersion for the below call - add a test
51 return new FileModelSource( pathTranslator.toFile( basedir, groupId, artifactId, version, filename ) );
54 public void addRepository( Repository repository )
55 throws InvalidRepositoryException
57 // we just ignore repositories outside of the current one for now
58 // TODO: it'd be nice to look them up from Archiva's set, but we want to do that by URL / mapping, not just the
59 // ID since they will rarely match
62 public ModelResolver newCopy()
64 return new RepositoryModelResolver( basedir, pathTranslator );