diff --git a/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java b/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java index bb6acf060a..037e6d54f9 100644 --- a/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java +++ b/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java @@ -56,7 +56,7 @@ import org.apache.maven.model.Exclusion; import org.apache.maven.model.Repository; 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.events.TransferListener; import org.apache.maven.wagon.proxy.ProxyInfo; @@ -188,7 +188,7 @@ public Artifact createPluginArtifact( String groupId, String artifactId, String * @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific */ public Set createArtifacts( List dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor ) - throws InvalidDependencyVersionException + throws VersionNotFoundException { Set projectArtifacts = new LinkedHashSet( dependencies.size() ); @@ -212,7 +212,7 @@ public Set createArtifacts( List dependencies, String inhe } 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(), versionRange, d.getType(), d.getClassifier(), diff --git a/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java b/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java index a288c275f3..c7d6c71e5f 100644 --- a/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java +++ b/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java @@ -33,7 +33,6 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.model.Repository; -import org.apache.maven.project.artifact.InvalidDependencyVersionException; 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 ); Set createArtifacts( List dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor ) - throws InvalidDependencyVersionException; + throws VersionNotFoundException; // Repository creation diff --git a/maven-repository/src/main/java/org/apache/maven/repository/VersionNotFoundException.java b/maven-repository/src/main/java/org/apache/maven/repository/VersionNotFoundException.java new file mode 100644 index 0000000000..728778af6d --- /dev/null +++ b/maven-repository/src/main/java/org/apache/maven/repository/VersionNotFoundException.java @@ -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 Brett Porter + * @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; + } +}