mirror of https://github.com/apache/maven.git
[MNG-8326] The ModelBuilder cannot import BOM with classifiers
This commit is contained in:
parent
912c1177ee
commit
c06965db88
|
@ -59,6 +59,7 @@ public interface ModelResolver extends Service {
|
||||||
parent.getGroupId(),
|
parent.getGroupId(),
|
||||||
parent.getArtifactId(),
|
parent.getArtifactId(),
|
||||||
parent.getVersion(),
|
parent.getVersion(),
|
||||||
|
null,
|
||||||
version -> modified.set(parent.withVersion(version)));
|
version -> modified.set(parent.withVersion(version)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +86,7 @@ public interface ModelResolver extends Service {
|
||||||
dependency.getGroupId(),
|
dependency.getGroupId(),
|
||||||
dependency.getArtifactId(),
|
dependency.getArtifactId(),
|
||||||
dependency.getVersion(),
|
dependency.getVersion(),
|
||||||
|
dependency.getClassifier(),
|
||||||
version -> modified.set(dependency.withVersion(version)));
|
version -> modified.set(dependency.withVersion(version)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +97,7 @@ public interface ModelResolver extends Service {
|
||||||
@Nonnull String groupId,
|
@Nonnull String groupId,
|
||||||
@Nonnull String artifactId,
|
@Nonnull String artifactId,
|
||||||
@Nonnull String version,
|
@Nonnull String version,
|
||||||
|
@Nullable String classifier,
|
||||||
@Nonnull Consumer<String> resolvedVersion)
|
@Nonnull Consumer<String> resolvedVersion)
|
||||||
throws ModelResolverException;
|
throws ModelResolverException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class DefaultModelResolver implements ModelResolver {
|
||||||
parent.getArtifactId(),
|
parent.getArtifactId(),
|
||||||
parent.getVersion(),
|
parent.getVersion(),
|
||||||
"parent",
|
"parent",
|
||||||
|
null,
|
||||||
parent.getLocation("version"),
|
parent.getLocation("version"),
|
||||||
version -> modified.set(parent.withVersion(version)));
|
version -> modified.set(parent.withVersion(version)));
|
||||||
}
|
}
|
||||||
|
@ -89,6 +90,7 @@ public class DefaultModelResolver implements ModelResolver {
|
||||||
dependency.getArtifactId(),
|
dependency.getArtifactId(),
|
||||||
dependency.getVersion(),
|
dependency.getVersion(),
|
||||||
"dependency",
|
"dependency",
|
||||||
|
dependency.getClassifier(),
|
||||||
dependency.getLocation("version"),
|
dependency.getLocation("version"),
|
||||||
version -> modified.set(dependency.withVersion(version)));
|
version -> modified.set(dependency.withVersion(version)));
|
||||||
}
|
}
|
||||||
|
@ -100,9 +102,11 @@ public class DefaultModelResolver implements ModelResolver {
|
||||||
@Nonnull String groupId,
|
@Nonnull String groupId,
|
||||||
@Nonnull String artifactId,
|
@Nonnull String artifactId,
|
||||||
@Nonnull String version,
|
@Nonnull String version,
|
||||||
|
@Nullable String classifier,
|
||||||
@Nonnull Consumer<String> resolvedVersion)
|
@Nonnull Consumer<String> resolvedVersion)
|
||||||
throws ModelResolverException {
|
throws ModelResolverException {
|
||||||
return resolveModel(session, repositories, groupId, artifactId, version, null, null, resolvedVersion);
|
return resolveModel(
|
||||||
|
session, repositories, groupId, artifactId, version, null, classifier, null, resolvedVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("checkstyle:ParameterNumber")
|
@SuppressWarnings("checkstyle:ParameterNumber")
|
||||||
|
@ -113,11 +117,13 @@ public class DefaultModelResolver implements ModelResolver {
|
||||||
String artifactId,
|
String artifactId,
|
||||||
String version,
|
String version,
|
||||||
String type,
|
String type,
|
||||||
|
String classifier,
|
||||||
InputLocation location,
|
InputLocation location,
|
||||||
Consumer<String> resolvedVersion)
|
Consumer<String> resolvedVersion)
|
||||||
throws ModelResolverException {
|
throws ModelResolverException {
|
||||||
try {
|
try {
|
||||||
ArtifactCoordinates coords = session.createArtifactCoordinates(groupId, artifactId, version, "pom");
|
ArtifactCoordinates coords =
|
||||||
|
session.createArtifactCoordinates(groupId, artifactId, version, classifier, "pom", null);
|
||||||
if (coords.getVersionConstraint().getVersionRange() != null
|
if (coords.getVersionConstraint().getVersionRange() != null
|
||||||
&& coords.getVersionConstraint().getVersionRange().getUpperBoundary() == null) {
|
&& coords.getVersionConstraint().getVersionRange().getUpperBoundary() == null) {
|
||||||
// Message below is checked for in the MNG-2199 core IT.
|
// Message below is checked for in the MNG-2199 core IT.
|
||||||
|
@ -143,7 +149,7 @@ public class DefaultModelResolver implements ModelResolver {
|
||||||
resolvedVersion.accept(newVersion);
|
resolvedVersion.accept(newVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path path = getPath(session, repositories, groupId, artifactId, newVersion);
|
Path path = getPath(session, repositories, groupId, artifactId, newVersion, classifier);
|
||||||
return new ResolverModelSource(path, groupId + ":" + artifactId + ":" + newVersion);
|
return new ResolverModelSource(path, groupId + ":" + artifactId + ":" + newVersion);
|
||||||
} catch (VersionRangeResolverException | ArtifactResolverException e) {
|
} catch (VersionRangeResolverException | ArtifactResolverException e) {
|
||||||
throw new ModelResolverException(
|
throw new ModelResolverException(
|
||||||
|
@ -163,9 +169,10 @@ public class DefaultModelResolver implements ModelResolver {
|
||||||
List<RemoteRepository> repositories,
|
List<RemoteRepository> repositories,
|
||||||
String groupId,
|
String groupId,
|
||||||
String artifactId,
|
String artifactId,
|
||||||
String newVersion) {
|
String version,
|
||||||
|
String classifier) {
|
||||||
DownloadedArtifact resolved = session.resolveArtifact(
|
DownloadedArtifact resolved = session.resolveArtifact(
|
||||||
session.createArtifactCoordinates(groupId, artifactId, newVersion, "pom"), repositories);
|
session.createArtifactCoordinates(groupId, artifactId, version, classifier, "pom", null), repositories);
|
||||||
return resolved.getPath();
|
return resolved.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase {
|
||||||
String groupId,
|
String groupId,
|
||||||
String artifactId,
|
String artifactId,
|
||||||
String version,
|
String version,
|
||||||
|
String classifier,
|
||||||
Consumer<String> resolvedVersion)
|
Consumer<String> resolvedVersion)
|
||||||
throws ModelResolverException {
|
throws ModelResolverException {
|
||||||
String id = groupId + ":" + artifactId + ":" + version;
|
String id = groupId + ":" + artifactId + ":" + version;
|
||||||
|
|
Loading…
Reference in New Issue