Example usage for org.apache.maven.artifact Artifact setVersionRange

List of usage examples for org.apache.maven.artifact Artifact setVersionRange

Introduction

In this page you can find the example usage for org.apache.maven.artifact Artifact setVersionRange.

Prototype

void setVersionRange(VersionRange newRange);

Source Link

Usage

From source file:com.github.panthers.maven.plugins.fromConfig.ArtifactItemsWithRange.java

License:Apache License

public ArtifactItemsWithRange(Artifact artifact) throws MojoFailureException {
    super(artifact);
    try {/*from   w ww  .ja v  a2  s  .c o m*/
        artifact.setVersionRange(VersionRange.createFromVersionSpec(versionRange));
    } catch (InvalidVersionSpecificationException e) {
        throw new MojoFailureException(
                "Please provide a valid version range." + " check VersionRange JDoc createFromVersionSpec");
    }
}

From source file:org.apache.aries.plugin.esa.stubs.EsaMavenProjectStub9.java

License:Apache License

public Set getArtifacts() {
    try {//from   w ww .  j  a  v  a 2  s .  co  m
        Set artifacts = new HashSet();

        artifacts.add(createArtifact("org.apache.maven.test", "maven-artifact01", "1.0-SNAPSHOT", false));
        Artifact artifact02 = createArtifact("org.apache.maven.test", "maven-artifact02", "1.0-SNAPSHOT",
                false);
        artifact02.setVersionRange(VersionRange.createFromVersionSpec("[1.3, 2.5)"));
        artifacts.add(artifact02);
        artifacts.add(createArtifact("org.apache.maven.test", "maven-artifact03", "1.1-SNAPSHOT", false));
        artifacts.add(createArtifact("org.apache.maven.test", "maven-artifact04", "1.2-SNAPSHOT", "esa", true));
        return artifacts;
    } catch (InvalidVersionSpecificationException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.echocat.jomon.maven.boot.ArtifactFactory.java

License:Mozilla Public License

@Nonnull
protected ArtifactResolutionResult resolve(@Nonnull MavenProject project, @Nonnull Artifact artifact,
        @Nonnull ArtifactFactoryRequest request, boolean resolveTransitively) throws Exception {
    if (artifact.getVersionRange() != null && artifact.getVersionRange().hasRestrictions()) {
        final String latestVersion = getLatestVersionOf(project, artifact);
        artifact.setVersionRange(createFromVersion(latestVersion));
    }//from  w  ww . j  a  v  a 2 s  .  c om

    final ArtifactResolutionRequest resolutionRequest = createRequestFor(project, artifact);
    resolutionRequest.setForceUpdate(request.isForceUpdate());
    resolutionRequest.setResolveTransitively(resolveTransitively);
    resolutionRequest.setResolutionFilter(toArtifactFilter(request));
    final ArtifactResolutionResult resolutionResult = _artifactResolver.resolve(resolutionRequest);
    _resolutionErrorHandler.throwErrors(resolutionRequest, resolutionResult);
    return resolutionResult;
}

From source file:org.jboss.tools.maven.core.internal.resolution.ArtifactResolutionService.java

License:Open Source License

List<String> getAvailableReleasedVersions(Artifact artifact, List<ArtifactRepository> repositories,
        IProgressMonitor monitor) throws CoreException {

    ArtifactMetadataSource source = getArtifactMetadataSource();

    IMaven maven = MavenPlugin.getMaven();
    ArtifactRepository localRepository = maven.getLocalRepository();
    try {/*from  w w  w .  j ava 2  s.  co  m*/
        String versionRangeSpec = artifact.getVersion() == null ? "[0,)" : artifact.getVersion(); //$NON-NLS-1$
        VersionRange versionRange = VersionRange.createFromVersionSpec(versionRangeSpec);
        artifact.setVersionRange(versionRange);
        List<ArtifactVersion> fullVersions = source.retrieveAvailableVersions(artifact, localRepository,
                repositories);
        List<String> versions = new ArrayList<String>(fullVersions.size());
        for (ArtifactVersion aVersion : fullVersions) {
            String version = aVersion.toString();
            if (version.endsWith("-SNAPSHOT")) { //$NON-NLS-1$
                continue;
            }
            if (versionRange.containsVersion(aVersion)) {
                versions.add(version);
            }
        }
        return versions;
    } catch (Exception e) {
        throw toCoreException(e);
    }
}