Search in sources :

Example 21 with MavenArtifact

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

the class CreateProducersMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (skip) {
        getLog().info("Skipping the create-producers goal.");
        return;
    }
    final MavenArtifact artifact = new MavenArtifact().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
    final MavenProducers installer = MavenProducers.getInstance(SimplisticMavenRepoManager.getInstance(Paths.get(project.getBuild().getDirectory()).resolve("local-repo"), new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories)), artifact);
    for (ProducerDescription producer : producers) {
        installer.addProducer(producer);
    }
    try {
        installer.install();
    } catch (MavenUniverseException e) {
        throw new MojoExecutionException("Failed to create producers artifact", e);
    }
    projectHelper.attachArtifact(project, "jar", artifact.getPath().toFile());
}
Also used : MavenProducers(org.jboss.galleon.universe.maven.MavenProducers) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenArtifactRepositoryManager(org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) MavenUniverseException(org.jboss.galleon.universe.maven.MavenUniverseException)

Example 22 with MavenArtifact

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

the class CreateUniverseMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (skip) {
        getLog().info("Skipping the create-universe goal.");
        return;
    }
    final MavenArtifact universeArtifact = new MavenArtifact().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
    final MavenUniverseInstaller installer = new MavenUniverseInstaller(SimplisticMavenRepoManager.getInstance(Paths.get(project.getBuild().getDirectory()).resolve("local-repo"), new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories)), universeArtifact);
    final Set<String> names = new HashSet<>(producers.size());
    for (ProducerSpec producer : producers) {
        if (!names.add(producer.name)) {
            throw new MojoExecutionException("Duplicate producer " + producer.name);
        }
        try {
            installer.addProducer(producer.name, producer.groupId, producer.artifactId, producer.versionRange);
        } catch (MavenUniverseException e) {
            throw new MojoExecutionException("Failed to add producer " + producer.name, e);
        }
    }
    try {
        installer.install();
    } catch (MavenUniverseException e) {
        throw new MojoExecutionException("Failed to create universe", e);
    }
    projectHelper.attachArtifact(project, "jar", universeArtifact.getPath().toFile());
}
Also used : MavenUniverseInstaller(org.jboss.galleon.universe.maven.MavenUniverseInstaller) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenArtifactRepositoryManager(org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) MavenUniverseException(org.jboss.galleon.universe.maven.MavenUniverseException) HashSet(java.util.HashSet)

Example 23 with MavenArtifact

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

the class FeaturePackInstallMojo method resolveMaven.

private Path resolveMaven(ArtifactCoordinate coordinate, MavenRepoManager resolver) throws MojoExecutionException {
    final MavenArtifact artifact = new MavenArtifact();
    artifact.setGroupId(coordinate.getGroupId());
    artifact.setArtifactId(coordinate.getArtifactId());
    artifact.setVersion(coordinate.getVersion());
    artifact.setExtension(coordinate.getExtension());
    artifact.setClassifier(coordinate.getClassifier());
    try {
        resolver.resolve(artifact);
    } catch (MavenUniverseException e) {
        throw new MojoExecutionException("Failed to resolve artifact " + artifact, e);
    }
    return artifact.getPath();
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) MavenUniverseException(org.jboss.galleon.universe.maven.MavenUniverseException)

Example 24 with MavenArtifact

use of org.jboss.galleon.universe.maven.MavenArtifact 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)

Example 25 with MavenArtifact

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

the class MavenRepoManager method resolve.

@Override
default Path resolve(String location) throws ProvisioningException {
    final MavenArtifact artifact = MavenArtifact.fromString(location);
    resolve(artifact);
    return artifact.getPath();
}
Also used : 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