Search in sources :

Example 1 with MavenArtifact

use of org.jboss.galleon.universe.maven.MavenArtifact in project wildfly-maven-plugin by wildfly.

the class LocalCLIExecutor method resolveCLI.

private static URL resolveCLI(MavenRepoManager artifactResolver) throws Exception {
    final URL[] cp = new URL[1];
    MavenArtifact mavenArtifact = new MavenArtifact();
    mavenArtifact.setGroupId(CLI_GROUP_ID);
    mavenArtifact.setArtifactId(CLI_ARTIFACT_ID);
    String version = retrieveCoreVersion(artifactResolver);
    mavenArtifact.setVersion(version);
    mavenArtifact.setClassifier(CLI_CLASSIFIER);
    mavenArtifact.setExtension(CLI_TYPE);
    artifactResolver.resolve(mavenArtifact);
    return mavenArtifact.getPath().toUri().toURL();
}
Also used : MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) URL(java.net.URL)

Example 2 with MavenArtifact

use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.

the class MavenProducerSpecXmlWriter method toElement.

@Override
protected ElementNode toElement(MavenProducerBase producer) throws XMLStreamException {
    final ElementNode producerEl = addElement(null, Element.PRODUCER);
    addAttribute(producerEl, Attribute.NAME, producer.getName());
    final MavenArtifact artifact = producer.getArtifact();
    String value = artifact.getGroupId();
    if (value == null) {
        throw new XMLStreamException("Producer " + producer.getName() + " is missing groupId");
    }
    addElement(producerEl, Element.GROUP_ID).addChild(new TextNode(value));
    value = artifact.getArtifactId();
    if (value == null) {
        throw new XMLStreamException("Producer " + producer.getName() + " is missing artifactId");
    }
    addElement(producerEl, Element.ARTIFACT_ID).addChild(new TextNode(value));
    value = artifact.getVersionRange();
    if (value == null) {
        throw new XMLStreamException("Producer " + producer.getName() + " is missing version-range");
    }
    addElement(producerEl, Element.VERSION_RANGE).addChild(new TextNode(value));
    return producerEl;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) TextNode(org.jboss.galleon.xml.util.TextNode) ElementNode(org.jboss.galleon.xml.util.ElementNode) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact)

Example 3 with MavenArtifact

use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.

the class FeaturePackLocationResolverTestCase method testResolutionLocalPathInstalled.

@Test
public void testResolutionLocalPathInstalled() throws Exception {
    FeaturePackLocation fpl = FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.0.0.Final");
    MavenArtifact artifact = new MavenArtifact().setGroupId(FP_GROUP_ID).setArtifactId(PRODUCER1_FP_ARTIFACT_ID).setExtension("zip").setVersion("5.0.0.Final");
    FeaturePackCreator.getInstance().addArtifactResolver(repo).newFeaturePack().setFPID(fpl.getFPID()).getCreator().install();
    Path path = resolver.resolve(fpl);
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    Path externalPath = repoHome.resolve("external").resolve(path.getFileName().toString());
    IoUtils.copy(path, externalPath);
    IoUtils.recursiveDelete(path);
    try {
        resolver.resolve(fpl);
        Assert.fail(String.format("The %s artifact is still installed in the local repository", artifact.getCoordsAsString()));
    } catch (ProvisioningException e) {
    // Expected exception
    }
    UniverseResolver resolver = UniverseResolver.builder().addArtifactResolver(repo).addLocalFeaturePack(externalPath).build();
    try {
        path = resolver.resolve(fpl);
        Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    } catch (ProvisioningException e) {
        Assert.fail(String.format("Cannot resolve %s artifact using a resolved with a local feature pack location", artifact.getCoordsAsString()));
    }
}
Also used : Path(java.nio.file.Path) ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) UniverseResolver(org.jboss.galleon.universe.UniverseResolver) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) Test(org.junit.Test)

Example 4 with MavenArtifact

use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.

the class FeaturePackLocationResolverTestCase method testMain.

@Test
public void testMain() throws Exception {
    try {
        resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
        Assert.fail("Artifact does not exist");
    } catch (ProvisioningException e) {
        final MavenArtifact artifact = new MavenArtifact();
        artifact.setGroupId(FP_GROUP_ID);
        artifact.setArtifactId(PRODUCER1_FP_ARTIFACT_ID);
        artifact.setExtension("zip");
        artifact.setVersionRange("[5.0-alpha,6.0-alpha)");
        Assert.assertEquals(MavenErrors.artifactNotFound(artifact, repoHome).getLocalizedMessage(), e.getLocalizedMessage());
    }
    installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.1.0.Alpha1"));
    try {
        resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
        Assert.fail("No final releases yet");
    } catch (ProvisioningException e) {
    // ignore
    }
    MavenArtifact artifact = new MavenArtifact().setGroupId(FP_GROUP_ID).setArtifactId(PRODUCER1_FP_ARTIFACT_ID).setExtension("zip").setVersion("5.1.0.Alpha1");
    Path path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):4#4.1.0.Beta2"));
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.2.0.Final"));
    artifact.setVersion("5.2.0.Final");
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.2.1.Beta1"));
    artifact.setVersion("5.2.1.Beta1");
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/beta"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
    artifact.setVersion("5.2.0.Final");
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):6#6.0.0.Alpha1"));
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
    artifact.setVersion("5.2.1.Beta1");
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):6#6.0.0.Final"));
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
    artifact.setVersion("5.2.0.Final");
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    artifact.setVersion("5.1.0.Alpha1");
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.1.0.Alpha1"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    artifact.setVersion("4.1.0.Beta2");
    path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#4.1.0.Beta2"));
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
}
Also used : Path(java.nio.file.Path) ProvisioningException(org.jboss.galleon.ProvisioningException) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) Test(org.junit.Test)

Example 5 with MavenArtifact

use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.

the class FeaturePackLocationResolverTestCase method doInit.

@Override
public void doInit() throws Exception {
    final MavenArtifact artifact = new MavenArtifact().setGroupId(GROUP_ID).setArtifactId(PRODUCER1_ARTIFACT_ID).setVersion("1.0.0.Final");
    MavenProducerInstaller producerInstaller = new MavenProducerInstaller("producer1", repo, artifact, FP_GROUP_ID, PRODUCER1_FP_ARTIFACT_ID);
    producerInstaller.addChannel("6", "[6.0-alpha,7.0-alpha)");
    producerInstaller.addChannel("5", "[5.0-alpha,6.0-alpha)");
    producerInstaller.addChannel("4", "[4.0-alpha,5.0-alpha)");
    producerInstaller.addFrequencies("alpha", "beta");
    producerInstaller.install();
    universeArt = new MavenArtifact().setGroupId(GROUP_ID).setArtifactId("universe1-artifact").setVersion("1.0.0.Final");
    final MavenUniverseInstaller universeInstaller = new MavenUniverseInstaller(repo, universeArt);
    universeInstaller.addProducer("producer1", GROUP_ID, PRODUCER1_ARTIFACT_ID, "[1.0.0,2.0.0)");
    universeInstaller.install();
    resolver = UniverseResolver.builder().addArtifactResolver(repo).build();
}
Also used : MavenProducerInstaller(org.jboss.galleon.universe.maven.MavenProducerInstaller) MavenUniverseInstaller(org.jboss.galleon.universe.maven.MavenUniverseInstaller) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact)

Aggregations

MavenArtifact (org.jboss.galleon.universe.maven.MavenArtifact)34 MavenProducerInstaller (org.jboss.galleon.universe.maven.MavenProducerInstaller)11 MavenUniverseInstaller (org.jboss.galleon.universe.maven.MavenUniverseInstaller)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)6 MavenUniverseException (org.jboss.galleon.universe.maven.MavenUniverseException)6 Path (java.nio.file.Path)5 Test (org.junit.Test)5 MavenArtifactRepositoryManager (org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager)3 HashSet (java.util.HashSet)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 ProvisioningException (org.jboss.galleon.ProvisioningException)2 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Artifact (org.apache.maven.artifact.Artifact)1 Dependency (org.apache.maven.model.Dependency)1 Model (org.apache.maven.model.Model)1 Parent (org.apache.maven.model.Parent)1 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)1