-
Notifications
You must be signed in to change notification settings - Fork 140
Description
Konrad Windszus opened MRESOLVER-597 and commented
I see the following exception when trying to resolve an artifact which does not have a version via
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
ArtifactResult result = repositorySystem.resolveArtifact(repositorySession, request);
java.lang.IllegalArgumentException: version can neither be null, empty nor blank
at org.apache.maven.artifact.ArtifactUtils.notBlank (ArtifactUtils.java:95)
at org.apache.maven.artifact.ArtifactUtils.key (ArtifactUtils.java:86)
at org.apache.maven.ReactorReader.findArtifact (ReactorReader.java:96)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:350)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:261)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:243)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact (DefaultRepositorySystem.java:278)
According to
maven-resolver/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
Line 137 in 362a436
| public DefaultArtifact(String groupId, String artifactId, String extension, String version) { |
DefaultArtifact may be null or empty. However not all Artifact objects are valid then for ArtifactRequest.
Although throwing an exception is totally valid here either the IllegalArgumentException should be documented in the javadoc of https://maven.apache.org/resolver/apidocs/org/eclipse/aether/RepositorySystem.html#resolveArtifact(org.eclipse.aether.RepositorySystemSession,org.eclipse.aether.resolution.ArtifactRequest).
IMHO it would make sense to throw the exception already when either populating or constructing the ArtifactRequest, as only non empty coordinates are supported.
Affects: 1.9.20