getting rid of project in the API layer

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@747923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Gusakov 2009-02-25 21:05:19 +00:00
parent 7b3b37986c
commit 34820bc86c
3 changed files with 63 additions and 5 deletions

View File

@ -56,7 +56,7 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion; import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.project.artifact.InvalidDependencyVersionException; //import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.proxy.ProxyInfo;
@ -188,7 +188,7 @@ public class LegacyMavenRepositorySystem
* @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific * @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific
*/ */
public Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor ) public Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor )
throws InvalidDependencyVersionException throws VersionNotFoundException
{ {
Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() ); Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() );
@ -212,7 +212,7 @@ public class LegacyMavenRepositorySystem
} }
catch ( InvalidVersionSpecificationException e ) catch ( InvalidVersionSpecificationException e )
{ {
throw new InvalidDependencyVersionException( reactor.getId(), d, reactor.getFile(), e ); throw new VersionNotFoundException( reactor.getId(), d, reactor.getFile(), e );
} }
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
versionRange, d.getType(), d.getClassifier(), versionRange, d.getType(), d.getClassifier(),

View File

@ -33,7 +33,6 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
/** /**
@ -63,7 +62,7 @@ public interface MavenRepositorySystem
Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope, String inheritedScope ); Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope, String inheritedScope );
Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor ) Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor )
throws InvalidDependencyVersionException; throws VersionNotFoundException;
// Repository creation // Repository creation

View File

@ -0,0 +1,59 @@
package org.apache.maven.repository;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.model.Dependency;
import java.io.File;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Thrown if a dependency has an invalid version.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class VersionNotFoundException
extends Exception
{
private Dependency dependency;
public VersionNotFoundException( String projectId
, Dependency dependency
, File pomFile
, InvalidVersionSpecificationException cause
)
{
super( projectId+", "+formatLocationInPom( dependency )+ " " +dependency.getVersion()+", pom file "+pomFile, cause );
this.dependency = dependency;
}
private static String formatLocationInPom( Dependency dependency )
{
return "Dependency: " + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() );
}
public Dependency getDependency()
{
return dependency;
}
}