apache/maven · error · ArtifactNotFoundException

Unable to determine the latest version

Error message

Unable to determine the latest version

What it means

LatestArtifactTransformation.transformForResolve handles artifacts whose literal version is 'LATEST'. It resolves the version from repository metadata; if resolveVersion still returns 'LATEST', no usable versioning metadata exists, and ArtifactNotFoundException('Unable to determine the latest version') is thrown for that artifact. A separate RepositoryMetadataResolutionException (metadata could not be read at all) is converted to ArtifactResolutionException instead.

Source

Thrown at compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java:47

import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;

/**
 * Describes a version transformation during artifact resolution - "latest" type
 */
@Named("latest")
@Singleton
@Deprecated
public class LatestArtifactTransformation extends AbstractVersionTransformation {

    @Override
    public void transformForResolve(Artifact artifact, RepositoryRequest request)
            throws ArtifactResolutionException, ArtifactNotFoundException {
        if (Artifact.LATEST_VERSION.equals(artifact.getVersion())) {
            try {
                String version = resolveVersion(artifact, request);
                if (Artifact.LATEST_VERSION.equals(version)) {
                    throw new ArtifactNotFoundException("Unable to determine the latest version", artifact);
                }

                artifact.setBaseVersion(version);
                artifact.updateVersion(version, request.getLocalRepository());
            } catch (RepositoryMetadataResolutionException e) {
                throw new ArtifactResolutionException(e.getMessage(), artifact, e);
            }
        }
    }

    @Override
    public void transformForInstall(Artifact artifact, ArtifactRepository localRepository) {
        // metadata is added via addPluginArtifactMetadata
    }

    @Override
    public void transformForDeployment(
            Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository) {

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Replace <version>LATEST</version> with a concrete version (or a bounded range) — the recommended, reproducible practice
  2. If LATEST must resolve, ensure the artifact has been deployed at least once so maven-metadata.xml exists in the target repository
  3. Refresh metadata with mvn -U and verify the repository is reachable and listed in the effective POM
  4. Check for typos in groupId/artifactId that would make metadata lookup target a non-existent artifact

Example fix

<!-- before -->
<dependency>
  <groupId>com.example</groupId>
  <artifactId>lib</artifactId>
  <version>LATEST</version>
</dependency>

<!-- after -->
<dependency>
  <groupId>com.example</groupId>
  <artifactId>lib</artifactId>
  <version>1.4.2</version>
</dependency>
Defensive patterns

Strategy: validation

Validate before calling

import org.apache.maven.artifact.Artifact;

boolean usesMetaversion(Artifact a) {
    String v = a.getVersion();
    return Artifact.LATEST_VERSION.equals(v) || Artifact.RELEASE_VERSION.equals(v);
}

if (usesMetaversion(artifact)) {
    throw new IllegalArgumentException(
        "LATEST/RELEASE metaversions make builds non-reproducible; pin a concrete version for "
            + artifact.getId());
}

Try / catch

try {
    transformer.transformForResolve(artifact, request);
} catch (ArtifactNotFoundException e) {
    if ("Unable to determine the latest version".equals(e.getMessage())) {
        // metadata absent: replace LATEST with a concrete version in the dependency declaration
        advisePinning(artifact);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: A dependency or plugin declared with <version>LATEST</version> where maven-metadata.xml for the artifact is absent from all reachable repositories or contains no usable versioning information (resolveVersion falls back to the LATEST marker).

Common situations: Using LATEST against a project that was never deployed so no metadata exists; internal mirror not serving metadata; offline builds without cached metadata; LATEST inherited from stale documentation or templates — also generally discouraged because it makes builds non-reproducible.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/95b22c5e43b23d91. Report an issue: GitHub.