Search in sources :

Example 11 with MavenUniverseException

use of org.jboss.galleon.universe.maven.MavenUniverseException 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 12 with MavenUniverseException

use of org.jboss.galleon.universe.maven.MavenUniverseException 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 13 with MavenUniverseException

use of org.jboss.galleon.universe.maven.MavenUniverseException 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 14 with MavenUniverseException

use of org.jboss.galleon.universe.maven.MavenUniverseException 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 15 with MavenUniverseException

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

the class LocalArtifactVersionRangeResolver method resolveLatestVersion.

public void resolveLatestVersion(MavenArtifact artifact, String lowestQualifier, Pattern includeVersion, Pattern excludeVersion) throws MavenUniverseException {
    if (artifact.isResolved()) {
        throw new MavenUniverseException("Artifact is already resolved");
    }
    Path path = resolveLatestVersionDir(artifact, lowestQualifier, includeVersion, excludeVersion);
    artifact.setVersion(path.getFileName().toString());
    path = path.resolve(artifact.getArtifactFileName());
    if (!Files.exists(path)) {
        throw new MavenUniverseException(pathDoesNotExist(artifact, path));
    }
    artifact.setPath(path);
}
Also used : Path(java.nio.file.Path) MavenUniverseException(org.jboss.galleon.universe.maven.MavenUniverseException)

Aggregations

MavenUniverseException (org.jboss.galleon.universe.maven.MavenUniverseException)16 Path (java.nio.file.Path)6 MavenArtifact (org.jboss.galleon.universe.maven.MavenArtifact)6 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 InstallationException (org.eclipse.aether.installation.InstallationException)3 VersionRangeResolutionException (org.eclipse.aether.resolution.VersionRangeResolutionException)3 MavenArtifactRepositoryManager (org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager)3 MavenLatestVersionNotAvailableException (org.jboss.galleon.universe.maven.MavenLatestVersionNotAvailableException)3 MavenProducer (org.jboss.galleon.universe.maven.MavenProducer)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)2 MavenProducerInstaller (org.jboss.galleon.universe.maven.MavenProducerInstaller)2 MavenUniverseInstaller (org.jboss.galleon.universe.maven.MavenUniverseInstaller)2 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 NoSuchElementException (java.util.NoSuchElementException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 InstallRequest (org.eclipse.aether.installation.InstallRequest)1 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)1