use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.
the class MavenUniverseFeaturePackCreatorTestCase method doInit.
@Override
protected void doInit() throws Exception {
final MavenProducerInstaller producer1 = new MavenProducerInstaller("producer1", repo, new MavenArtifact().setGroupId("universe.producer.maven.test").setArtifactId("maven-producer1").setVersion("1.0.0.Final"), "universe.feature-pack.maven.test", "feature-pack1").addFrequencies("alpha", "beta").addChannel("1.0", "[1.0.0,2.0.0)").install();
new MavenUniverseInstaller(repo, new MavenArtifact().setGroupId("universe.maven.test").setArtifactId("maven-universe1").setVersion("1.0.0.Final")).addProducer(producer1.getName(), producer1.getArtifact().setPath(null).setVersionRange("[1.0,2.0-alpha)")).install();
FeaturePackCreator.getInstance().addArtifactResolver(repo).newFeaturePack().setFPID(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + "(universe.maven.test:maven-universe1:[1.0,2.0-alpha)):1.0#1.0.0.Final").getFPID()).newPackage("p1", true).writeContent("p1.txt", "p1 text").getFeaturePack().getCreator().install();
}
use of org.jboss.galleon.universe.maven.MavenArtifact in project wildfly-maven-plugin by wildfly.
the class LocalCLIExecutor method retrieveCoreVersion.
private static String retrieveCoreVersion(MavenRepoManager artifactResolver) throws Exception {
InputStream is = LocalCLIExecutor.class.getResourceAsStream("/META-INF/maven/plugin.xml");
if (is == null) {
throw new MojoExecutionException("Can't retrieve plugin descriptor");
}
PluginDescriptorBuilder builder = new PluginDescriptorBuilder();
PluginDescriptor pluginDescriptor = builder.build(new InputStreamReader(is, StandardCharsets.UTF_8));
MavenArtifact mavenArtifact = new MavenArtifact();
mavenArtifact.setGroupId(pluginDescriptor.getGroupId());
mavenArtifact.setArtifactId(pluginDescriptor.getArtifactId());
mavenArtifact.setVersion(pluginDescriptor.getVersion());
mavenArtifact.setExtension("pom");
artifactResolver.resolve(mavenArtifact);
Model model = readModel(mavenArtifact.getPath());
Parent artifactParent = model.getParent();
MavenArtifact parentArtifact = new MavenArtifact();
parentArtifact.setGroupId(artifactParent.getGroupId());
parentArtifact.setArtifactId(artifactParent.getArtifactId());
parentArtifact.setVersion(artifactParent.getVersion());
parentArtifact.setExtension("pom");
artifactResolver.resolve(parentArtifact);
Model parentModel = readModel(parentArtifact.getPath());
return parentModel.getProperties().getProperty(WILDLY_CORE_VERSION_PROPERTY);
}
use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.
the class ProvisionStateMojo method resolveMaven.
private Path resolveMaven(ArtifactCoordinate coordinate, MavenRepoManager resolver) throws MavenUniverseException, MojoExecutionException {
final MavenArtifact artifact = new MavenArtifact();
artifact.setGroupId(coordinate.getGroupId());
artifact.setArtifactId(coordinate.getArtifactId());
String version = coordinate.getVersion();
if (isEmptyOrNull(version)) {
// direct dependencies may override the managed versions
for (Artifact a : project.getArtifacts()) {
if (coordinate.getArtifactId().equals(a.getArtifactId()) && coordinate.getGroupId().equals(a.getGroupId()) && coordinate.getExtension().equals(a.getType()) && (coordinate.getClassifier() == null ? "" : coordinate.getClassifier()).equals(a.getClassifier() == null ? "" : a.getClassifier())) {
version = a.getVersion();
break;
}
}
if (isEmptyOrNull(version)) {
// Now we are going to look for for among the managed dependencies
for (Dependency d : project.getDependencyManagement().getDependencies()) {
if (coordinate.getArtifactId().equals(d.getArtifactId()) && coordinate.getGroupId().equals(d.getGroupId()) && coordinate.getExtension().equals(d.getType()) && (coordinate.getClassifier() == null ? "" : coordinate.getClassifier()).equals(d.getClassifier() == null ? "" : d.getClassifier())) {
version = d.getVersion();
break;
}
}
if (isEmptyOrNull(version)) {
throw new MojoExecutionException(coordinate.getGroupId() + ":" + coordinate.getArtifactId() + ":" + (coordinate.getClassifier() == null ? "" : coordinate.getClassifier()) + ":" + coordinate.getExtension() + " was found among neither the project's dependencies nor the managed dependencies." + " To proceed, please, add the desired version of the feature-pack to the provisioning configuration" + " or the project dependencies, or the dependency management section of the Maven project");
}
}
}
artifact.setVersion(version);
artifact.setExtension(coordinate.getExtension());
artifact.setClassifier(coordinate.getClassifier());
resolver.resolve(artifact);
return artifact.getPath();
}
use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.
the class AbstractMavenArtifactRepositoryManager method getAllVersions.
@Override
public List<String> getAllVersions(MavenArtifact mavenArtifact, Pattern includeVersion, Pattern excludeVersion) throws MavenUniverseException {
Artifact artifact = new DefaultArtifact(mavenArtifact.getGroupId(), mavenArtifact.getArtifactId(), mavenArtifact.getExtension(), mavenArtifact.getVersionRange());
VersionRangeResult rangeResult = getVersionRange(artifact);
List<String> versions = new ArrayList<>();
for (Version v : rangeResult.getVersions()) {
String vString = v.toString();
if ((includeVersion == null || includeVersion.matcher(vString).matches()) && (excludeVersion == null || !excludeVersion.matcher(vString).matches())) {
versions.add(vString);
}
}
return versions;
}
use of org.jboss.galleon.universe.maven.MavenArtifact in project galleon by wildfly.
the class CreateProducerMojo method createProducer.
private void createProducer() throws MavenUniverseException, MojoExecutionException {
final MavenArtifact producerArtifact = new MavenArtifact().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
final MavenProducerInstaller installer = new MavenProducerInstaller(name, SimplisticMavenRepoManager.getInstance(Paths.get(project.getBuild().getDirectory()).resolve("local-repo"), new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories)), producerArtifact, featurePackGroupId, featurePackArtifactId);
for (String frequency : frequencies) {
installer.addFrequency(frequency);
}
final Set<String> names = new HashSet<>(channels.size());
for (ChannelDescription channel : channels) {
if (!names.add(channel.name)) {
throw new MojoExecutionException("Duplicate channel " + channel.name);
}
try {
installer.addChannel(channel.name, channel.versionRange);
} catch (MavenUniverseException e) {
throw new MojoExecutionException("Failed to add channel " + channel.name, e);
}
}
try {
installer.install();
} catch (MavenUniverseException e) {
throw new MojoExecutionException("Failed to create producer", e);
}
projectHelper.attachArtifact(project, "jar", producerArtifact.getPath().toFile());
}
Aggregations