Hi,
i have the following code which should resolve an artifact given GAV etc.

so far so good...

   /**
     * The project currently being build.
     */
    @Parameter( defaultValue = "${project}" )
    private MavenProject mavenProject;

    /**
     * The current Maven session.
     */
    @Parameter( defaultValue = "${session}" )
    private MavenSession mavenSession;

    @Component
    private ArtifactHandler artifactHandler;

    @Component
    private RepositorySystem repository;

private ArtifactResolutionResult resolve( String groupId, String artifactId, String version, String type )
        throws InvalidVersionSpecificationException
    {
VersionRange versionRange = VersionRange.createFromVersion( version );

        Artifact artifact =
new DefaultArtifact( groupId, artifactId, versionRange, Artifact.SCOPE_COMPILE, type, null, artifactHandler );

ArtifactResolutionRequest request = new ArtifactResolutionRequest();
        request.setArtifact( artifact )
            .setResolveRoot( true )
            .setResolveTransitively( false )
            .setServers( mavenSession.getRequest().getServers() )
            .setMirrors( mavenSession.getRequest().getMirrors() )
            .setProxies( mavenSession.getRequest().getProxies() )
            .setLocalRepository( mavenSession.getLocalRepository() )
.setRemoteRepositories( mavenSession.getRequest().getRemoteRepositories() );

        return repository.resolve( request );
    }


My intention was to get the information if of a given artifact newer versions exist so i thought to use a version range in the above code like this:


VersionRange versionRange = VersionRange.createFromVersionSpec( "[" + version + ",)");

which fails...it results in checking with a filename on the filesystem which contains the version range specifier but not does not solving the version range...


[INFO] Downloading: file:///Users/kama/.m2/repository/junit/junit/[3.8,)/junit-[3.8,)


The question is: How can i check if a newer version of a given artifact exists?

I have found the implementations in versions-maven-plugin but they look like an overkill for me for simply check if there are newer versions available or not...There i need a VersionsHelper etc. etc....


May be someone has a better simpler idea?

Many thanks in advance.

Kind regards
Karl-Heinz Marbaise





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to