Search in sources :

Example 1 with MavenProducer

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

the class MavenProducerExtendAndInstallTestCase method testMain.

@Test
public void testMain() throws Exception {
    final String fpGroupId = "channel-group1";
    final String fpArtifactId = "channel-artifact1";
    MavenProducerInstaller producerInstaller = new MavenProducerInstaller("producer1", repo, producer100Artifact, fpGroupId, fpArtifactId);
    producerInstaller.addFrequencies("alpha", "beta");
    producerInstaller.addChannel("1.0", "[1.0.0,2.0.0)");
    producerInstaller.addChannel("2.0", "[2.0.0,3.0.0)", false, ".*-ext-[0-9][0-9]", ".*-ext-11");
    producerInstaller.install();
    producerInstaller = new MavenProducerInstaller("producer1", repo, producer101Artifact, producer100Artifact);
    producerInstaller.removeFrequency("beta");
    producerInstaller.addFrequency("cr");
    producerInstaller.addChannel("3.0", "[3.0.0,4.0.0)");
    producerInstaller.removeChannel("1.0");
    producerInstaller.install();
    producer101Artifact.setPath(null);
    MavenProducer producer = new MavenProducer("producer1", repo, producer101Artifact);
    Collection<String> frequencies = producer.getFrequencies();
    Assert.assertEquals(3, frequencies.size());
    Assert.assertTrue(frequencies.contains("alpha"));
    Assert.assertTrue(frequencies.contains("cr"));
    Assert.assertTrue(frequencies.contains("final"));
    MavenChannel channel = producer.getChannel("2.0");
    Assert.assertEquals(fpGroupId, channel.getFeaturePackGroupId());
    Assert.assertEquals(fpArtifactId, channel.getFeaturePackArtifactId());
    Assert.assertEquals("[2.0.0,3.0.0)", channel.getVersionRange());
    Assert.assertEquals(".*-ext-[0-9][0-9]", channel.getVersionIncludeRegex());
    Assert.assertEquals(".*-ext-11", channel.getVersionExcludeRegex());
    frequencies = channel.getFrequencies();
    Assert.assertEquals(3, frequencies.size());
    Assert.assertTrue(frequencies.contains("alpha"));
    Assert.assertTrue(frequencies.contains("cr"));
    Assert.assertTrue(frequencies.contains("final"));
    Assert.assertTrue(producer.hasChannel("2.0"));
    Assert.assertTrue(producer.hasChannel("3.0"));
    channel = producer.getChannel("3.0");
    Assert.assertEquals(fpGroupId, channel.getFeaturePackGroupId());
    Assert.assertEquals(fpArtifactId, channel.getFeaturePackArtifactId());
    Assert.assertEquals("[3.0.0,4.0.0)", channel.getVersionRange());
    frequencies = channel.getFrequencies();
    Assert.assertEquals(3, frequencies.size());
    Assert.assertTrue(frequencies.contains("alpha"));
    Assert.assertTrue(frequencies.contains("cr"));
    Assert.assertTrue(frequencies.contains("final"));
    Assert.assertFalse(producer.hasChannel("4.0"));
    Assert.assertEquals(2, producer.getChannels().size());
}
Also used : MavenProducerInstaller(org.jboss.galleon.universe.maven.MavenProducerInstaller) MavenProducer(org.jboss.galleon.universe.maven.MavenProducer) MavenChannel(org.jboss.galleon.universe.maven.MavenChannel) Test(org.junit.Test)

Example 2 with MavenProducer

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

the class MavenProducerInstallTestCase method testMain.

@Test
public void testMain() throws Exception {
    final String fpGroupId = "fp-group1";
    final String fpArtifactId = "fp-artifact1";
    final MavenProducerInstaller producerInstaller = new MavenProducerInstaller("producer1", repo, producerArtifact, fpGroupId, fpArtifactId);
    producerInstaller.addFrequencies("alpha", "beta");
    producerInstaller.addChannel("1.0", "[1.0.0,2.0.0)");
    producerInstaller.addChannel("2.0", "[2.0.0,3.0.0)", false, ".*-ext-[0-9][0-9]", ".*-ext-11");
    producerInstaller.install();
    producerArtifact.setPath(null);
    MavenProducer producer = new MavenProducer("producer1", repo, producerArtifact);
    Assert.assertEquals(fpGroupId, producer.getFeaturePackGroupId());
    Assert.assertEquals(fpArtifactId, producer.getFeaturePackArtifactId());
    Collection<String> frequencies = producer.getFrequencies();
    Assert.assertEquals(3, frequencies.size());
    Assert.assertTrue(frequencies.contains("alpha"));
    Assert.assertTrue(frequencies.contains("beta"));
    Assert.assertTrue(frequencies.contains("final"));
    Assert.assertTrue(producer.hasChannel("1.0"));
    MavenChannel channel = producer.getChannel("1.0");
    Assert.assertEquals(fpGroupId, channel.getFeaturePackGroupId());
    Assert.assertEquals(fpArtifactId, channel.getFeaturePackArtifactId());
    Assert.assertEquals("[1.0.0,2.0.0)", channel.getVersionRange());
    frequencies = channel.getFrequencies();
    Assert.assertEquals(3, frequencies.size());
    Assert.assertTrue(frequencies.contains("alpha"));
    Assert.assertTrue(frequencies.contains("beta"));
    Assert.assertTrue(frequencies.contains("final"));
    channel = producer.getChannel("2.0");
    Assert.assertEquals(fpGroupId, channel.getFeaturePackGroupId());
    Assert.assertEquals(fpArtifactId, channel.getFeaturePackArtifactId());
    Assert.assertEquals("[2.0.0,3.0.0)", channel.getVersionRange());
    Assert.assertEquals(".*-ext-[0-9][0-9]", channel.getVersionIncludeRegex());
    Assert.assertEquals(".*-ext-11", channel.getVersionExcludeRegex());
    frequencies = channel.getFrequencies();
    Assert.assertEquals(3, frequencies.size());
    Assert.assertTrue(frequencies.contains("alpha"));
    Assert.assertTrue(frequencies.contains("beta"));
    Assert.assertTrue(frequencies.contains("final"));
    Assert.assertTrue(producer.hasChannel("2.0"));
    Assert.assertFalse(producer.hasChannel("3.0"));
    try {
        producer.getChannel("3.0");
    } catch (MavenUniverseException e) {
        Assert.assertEquals(MavenErrors.channelNotFound(producer.getName(), "3.0").getLocalizedMessage(), e.getLocalizedMessage());
    }
    Assert.assertEquals(2, producer.getChannels().size());
}
Also used : MavenProducerInstaller(org.jboss.galleon.universe.maven.MavenProducerInstaller) MavenProducer(org.jboss.galleon.universe.maven.MavenProducer) MavenChannel(org.jboss.galleon.universe.maven.MavenChannel) MavenUniverseException(org.jboss.galleon.universe.maven.MavenUniverseException) Test(org.junit.Test)

Example 3 with MavenProducer

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

the class MavenUniverseInstallTestCase method testMain.

@Test
public void testMain() throws Exception {
    final MavenUniverseInstaller universeInstaller = new MavenUniverseInstaller(repo, universeArtifact);
    universeInstaller.addProducer("producer1", GROUP_ID, "producer1", "[1.0.0,2.0.0)");
    universeInstaller.addProducer("producer2", GROUP_ID, "producer2", "[3.0.0,4.0.0)");
    universeInstaller.install();
    universeArtifact.setPath(null);
    final MavenUniverse universe = new MavenUniverse(repo, universeArtifact);
    Assert.assertTrue(universe.hasProducer("producer1"));
    MavenProducer producer = universe.getProducer("producer1");
    Assert.assertEquals(GROUP_ID, producer.getArtifact().getGroupId());
    Assert.assertEquals("producer1", producer.getArtifact().getArtifactId());
    Assert.assertEquals("[1.0.0,2.0.0)", producer.getArtifact().getVersionRange());
    producer = universe.getProducer("producer2");
    Assert.assertEquals(GROUP_ID, producer.getArtifact().getGroupId());
    Assert.assertEquals("producer2", producer.getArtifact().getArtifactId());
    Assert.assertEquals("[3.0.0,4.0.0)", producer.getArtifact().getVersionRange());
    Assert.assertTrue(universe.hasProducer("producer2"));
    Assert.assertFalse(universe.hasProducer("producerN"));
    try {
        universe.getProducer("producerN");
    } catch (MavenUniverseException e) {
        Assert.assertEquals(MavenErrors.producerNotFound("producerN").getLocalizedMessage(), e.getLocalizedMessage());
    }
    Assert.assertEquals(2, universe.getProducers().size());
}
Also used : MavenUniverse(org.jboss.galleon.universe.maven.MavenUniverse) MavenUniverseInstaller(org.jboss.galleon.universe.maven.MavenUniverseInstaller) MavenProducer(org.jboss.galleon.universe.maven.MavenProducer) MavenUniverseException(org.jboss.galleon.universe.maven.MavenUniverseException) Test(org.junit.Test)

Example 4 with MavenProducer

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

the class UniverseManager method resolveBuiltinUniverse.

/**
 * Universe resolution is done in a separate thread to not impact startup
 * time.
 */
synchronized void resolveBuiltinUniverse() {
    if (closed) {
        return;
    }
    Future<?> f = executorService.submit(() -> {
        synchronized (UniverseManager.this) {
            if (closed) {
                return;
            }
            try {
                List<FeaturePackLocation> deps = new ArrayList<>();
                builtinUniverse = (MavenUniverse) universeResolver.getUniverse(builtinUniverseSpec, true);
                if (closed) {
                    return;
                }
                // speed-up future completion and execution by retrieving producers and channels
                for (Producer<?> p : builtinUniverse.getProducers()) {
                    final MavenProducer mvnProducer = (MavenProducer) p;
                    if (mvnProducer.isResolvedLocally()) {
                        mvnProducer.refresh();
                    }
                    if (closed) {
                        return;
                    }
                    for (Channel c : p.getChannels()) {
                        if (closed) {
                            return;
                        }
                        FeaturePackLocation ploc = new FeaturePackLocation(builtinUniverseSpec, p.getName(), c.getName(), null, null);
                        deps.add(ploc);
                    }
                }
            } catch (Exception ex) {
                CliLogging.exceptionResolvingBuiltinUniverse(ex);
            }
        }
    });
    submited.add(f);
}
Also used : MavenProducer(org.jboss.galleon.universe.maven.MavenProducer) Channel(org.jboss.galleon.universe.Channel) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 5 with MavenProducer

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

the class MavenProducerSpecXmlParser10 method readElement.

@Override
public void readElement(XMLExtendedStreamReader reader, ParsedCallbackHandler<MavenUniverse, MavenProducer> builder) throws XMLStreamException {
    String name = null;
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case NAME:
                name = reader.getAttributeValue(i);
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (name == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.NAME));
    }
    final MavenArtifact artifact = new MavenArtifact();
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT:
                {
                    try {
                        builder.parsed(new MavenProducer(name, builder.getParent().getRepo(), artifact));
                    } catch (MavenUniverseException e) {
                        throw new XMLStreamException(getParserMessage("Failed to instantiate producer " + name, reader.getLocation()), e);
                    }
                    return;
                }
            case XMLStreamConstants.START_ELEMENT:
                {
                    final Element element = Element.of(reader.getName());
                    switch(element) {
                        case GROUP_ID:
                            artifact.setGroupId(reader.getElementText());
                            break;
                        case ARTIFACT_ID:
                            artifact.setArtifactId(reader.getElementText());
                            break;
                        case VERSION_RANGE:
                            artifact.setVersionRange(reader.getElementText());
                            break;
                        default:
                            throw ParsingUtils.unexpectedContent(reader);
                    }
                    break;
                }
            default:
                {
                    throw ParsingUtils.unexpectedContent(reader);
                }
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) MavenProducer(org.jboss.galleon.universe.maven.MavenProducer) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) MavenUniverseException(org.jboss.galleon.universe.maven.MavenUniverseException)

Aggregations

MavenProducer (org.jboss.galleon.universe.maven.MavenProducer)6 Test (org.junit.Test)4 MavenUniverseException (org.jboss.galleon.universe.maven.MavenUniverseException)3 XMLStreamException (javax.xml.stream.XMLStreamException)2 MavenChannel (org.jboss.galleon.universe.maven.MavenChannel)2 MavenProducerInstaller (org.jboss.galleon.universe.maven.MavenProducerInstaller)2 MavenUniverse (org.jboss.galleon.universe.maven.MavenUniverse)2 MavenUniverseInstaller (org.jboss.galleon.universe.maven.MavenUniverseInstaller)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 Channel (org.jboss.galleon.universe.Channel)1 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)1 MavenArtifact (org.jboss.galleon.universe.maven.MavenArtifact)1