Example usage for org.apache.maven.artifact.versioning VersionRange createFromVersion

List of usage examples for org.apache.maven.artifact.versioning VersionRange createFromVersion

Introduction

In this page you can find the example usage for org.apache.maven.artifact.versioning VersionRange createFromVersion.

Prototype

public static VersionRange createFromVersion(String version) 

Source Link

Usage

From source file:org.gradle.api.publication.maven.internal.ant.AbstractMavenPublish.java

License:Apache License

private Artifact createMainArtifact(ParsedMavenPom pom) {
    return new DefaultArtifact(pom.getGroup(), pom.getArtifactId(),
            VersionRange.createFromVersion(pom.getVersion()), null, pom.getPackaging(), null,
            artifactHandler(pom.getPackaging()));
}

From source file:org.gradle.api.publication.maven.internal.ant.AbstractMavenPublish.java

License:Apache License

private Artifact createPomArtifact(ParsedMavenPom pom) {
    return new DefaultArtifact(pom.getGroup(), pom.getArtifactId(),
            VersionRange.createFromVersion(pom.getVersion()), null, "pom", null, artifactHandler("pom"));
}

From source file:org.hardisonbrewing.maven.core.DependencyService.java

License:Open Source License

/**
 * Create the {#link Artifact} for the specified {@link Dependency}.
 * @param dependency The {@link Dependency} to create the {@link Artifact} for.
 * @return//from   ww w. j a va  2 s.c  o  m
 */
public static final Artifact createDependencyArtifact(Dependency dependency) {

    ArtifactFactory artifactFactory = getArtifactFactory();
    VersionRange versionRange = VersionRange.createFromVersion(dependency.getVersion());
    return artifactFactory.createDependencyArtifact(dependency.getGroupId(), dependency.getArtifactId(),
            versionRange, dependency.getType(), dependency.getClassifier(), dependency.getScope(),
            dependency.isOptional());
}

From source file:org.jasig.maven.legal.stubs.BasicProjectStub.java

License:Apache License

/** {@inheritDoc} */
@Override//w  ww  . j  a v a  2  s.  c om
public Set<Artifact> getDependencyArtifacts() {
    Artifact artifact1 = new DefaultArtifact("junit", "junit", VersionRange.createFromVersion("3.8.1"),
            Artifact.SCOPE_TEST, "jar", null, new DefaultArtifactHandler("jar"), false);

    Artifact artifact2 = new DefaultArtifact("org.apache.maven", "maven-project",
            VersionRange.createFromVersion("2.2.0"), Artifact.SCOPE_COMPILE, "jar", null,
            new DefaultArtifactHandler("jar"), false);

    final List<Artifact> artifacts = Arrays.asList(artifact1, artifact2);
    return Collections.unmodifiableSet(new LinkedHashSet<Artifact>(artifacts));
}

From source file:org.jasig.maven.legal.stubs.PluginArtifactStub.java

License:Apache License

/**
 * @param groupId//  ww w . j a v  a  2s .  c om
 * @param artifactId
 * @param version
 * @param packaging
 */
public PluginArtifactStub(String groupId, String artifactId, String version, String packaging) {
    this.groupId = groupId;
    this.artifactId = artifactId;
    this.version = version;
    this.packaging = packaging;
    versionRange = VersionRange.createFromVersion(version);
}

From source file:org.jenkinsci.tools.bce.JenkinsBCEMojo.java

License:Open Source License

/**
 * Creates a JAR artifact from Maven Coordinates.
 *
 * @return The created artifact. Must be resolved.
 *//*from   www  .  j a  va  2s.  com*/
private Artifact createArtifact(String groupId, String artifactId, String version) {
    return new DefaultArtifact(groupId, artifactId, VersionRange.createFromVersion(version),
            Artifact.SCOPE_COMPILE, "jar", null, new DefaultArtifactHandler("jar"));
}

From source file:org.jetbrains.idea.maven.server.embedder.Maven2ServerEmbedderImpl.java

License:Apache License

@Nonnull
@Override/*www. j a  v a 2 s .  c  o m*/
public List<String> retrieveAvailableVersions(@Nonnull String groupId, @Nonnull String artifactId,
        @Nonnull List<MavenRemoteRepository> remoteRepositories) throws RemoteException {
    try {
        Artifact artifact = new DefaultArtifact(groupId, artifactId, VersionRange.createFromVersion(""),
                Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
        ArtifactRepositoryLayout repositoryLayout = getComponent(ArtifactRepositoryLayout.class);
        List versions = getComponent(ArtifactMetadataSource.class).retrieveAvailableVersions(artifact,
                new DefaultArtifactRepository("local", getLocalRepositoryFile().getPath(), repositoryLayout),
                convertRepositories(remoteRepositories));

        List<String> result = new ArrayList<String>();
        for (Object version : versions) {
            result.add(version.toString());
        }
        return result;
    } catch (Exception e) {
        Maven2ServerGlobals.getLogger().info(e);
    }
    return Collections.emptyList();
}

From source file:org.kohsuke.maven.pgp.PgpMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    if (skip)/*from  w  w  w.ja  va2 s .c  om*/
        return;

    // capture the attached artifacts to sign before we start attaching our own stuff
    List<Artifact> attached = new ArrayList<Artifact>((List<Artifact>) project.getAttachedArtifacts());

    PGPSecretKey secretKey = loadSecretKey();
    Signer signer = new Signer(secretKey, loadPassPhrase(secretKey).toCharArray());

    if (!"pom".equals(project.getPackaging()))
        sign(signer, project.getArtifact());

    {// sign POM
        File pomToSign = new File(project.getBuild().getDirectory(),
                project.getBuild().getFinalName() + ".pom");

        try {
            FileUtils.copyFile(project.getFile(), pomToSign);
        } catch (IOException e) {
            throw new MojoExecutionException("Error copying POM for signing.", e);
        }

        getLog().debug("Generating signature for " + pomToSign);

        // fake just enough Artifact for the sign method
        DefaultArtifact a = new DefaultArtifact(project.getGroupId(), project.getArtifactId(),
                VersionRange.createFromVersion(project.getVersion()), null, "pom", null,
                new DefaultArtifactHandler("pom"));
        a.setFile(pomToSign);

        sign(signer, a);
    }

    for (Artifact a : attached)
        sign(signer, a);
}

From source file:org.metaeffekt.dita.maven.generation.AttachedPdfArtifact.java

License:Apache License

public AttachedPdfArtifact(Artifact artifact, ArtifactHandler handler, File file, String artifactId,
        String classifier, String artifactVersion) {
    super(artifact.getGroupId(), // groupId
            artifactId, // artifactId
            VersionRange.createFromVersion(artifactVersion), // version
            artifact.getScope(), // scope
            "pdf", // type
            classifier, // classifier
            new Handler(null, null), true); // artifactHandler
    setFile(file);/*from ww  w .  j  a v a2 s. c o  m*/
}

From source file:org.metaeffekt.dita.maven.generation.AttachedZipArtifact.java

License:Apache License

public AttachedZipArtifact(Artifact artifact, ArtifactHandler handler, File file, String artifactId,
        String classifier, String artifactVersion) {
    super(artifact.getGroupId(), // groupId
            artifactId, // artifactId
            VersionRange.createFromVersion(artifactVersion), // version
            artifact.getScope(), // scope
            "zip", // type
            classifier, // classifier
            new Handler(null, null), true); // artifactHandler
    setFile(file);//from  w  w w  .  j  a v a  2  s  . c  o  m
}