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());
}
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());
}
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();
}
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());
}
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);
}
Aggregations