use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project intellij-community by JetBrains.
the class Maven3ServerEmbedder method retrieveAvailableVersions.
@NotNull
@Override
public List<String> retrieveAvailableVersions(@NotNull String groupId, @NotNull String artifactId, @NotNull List<MavenRemoteRepository> remoteRepositories) throws RemoteException {
try {
Artifact artifact = new DefaultArtifact(groupId, artifactId, "", Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
List<ArtifactVersion> versions = getComponent(ArtifactMetadataSource.class).retrieveAvailableVersions(artifact, getLocalRepository(), convertRepositories(remoteRepositories));
return ContainerUtil.map(versions, new Function<ArtifactVersion, String>() {
@Override
public String fun(ArtifactVersion version) {
return version.toString();
}
});
} catch (Exception e) {
Maven3ServerGlobals.getLogger().info(e);
}
return Collections.emptyList();
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project bnd by bndtools.
the class IndexerMojo method attach.
private void attach(File file, String type, String extension) {
DefaultArtifactHandler handler = new DefaultArtifactHandler(type);
handler.setExtension(extension);
DefaultArtifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), null, type, null, handler);
artifact.setFile(file);
project.addAttachedArtifact(artifact);
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project kie-wb-common by kiegroup.
the class MavenUtils method createArtifacts.
private static void createArtifacts(List<Dependency> pomDeps, List<Artifact> deps) {
if (pomDeps != null && pomDeps.size() > 0) {
for (Dependency dep : pomDeps) {
Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getScope(), dep.getType(), dep.getClassifier(), new DefaultArtifactHandler());
deps.add(artifact);
}
}
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project felix by apache.
the class AbstractBundlePluginTest method getMavenProjectStub.
protected MavenProjectStub getMavenProjectStub() {
MavenProjectStub project = new MavenProjectStub();
project.setGroupId("group");
project.setArtifactId("project");
project.setVersion("1.2.3.4");
VersionRange versionRange = VersionRange.createFromVersion(project.getVersion());
ArtifactHandler artifactHandler = new DefaultArtifactHandler("pom");
Artifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), versionRange, null, "pom", null, artifactHandler);
artifact.setResolved(true);
project.setArtifact(artifact);
ProjectBuilderConfiguration projectBuilderConfiguration = new DefaultProjectBuilderConfiguration();
ArtifactRepositoryLayout layout = new LegacyRepositoryLayout();
ArtifactRepository artifactRepository = new DefaultArtifactRepository("scratch", new File(getBasedir(), "target" + File.separatorChar + "scratch").toURI().toString(), layout);
projectBuilderConfiguration.setLocalRepository(artifactRepository);
project.setProjectBuilderConfiguration(projectBuilderConfiguration);
return project;
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project drools by kiegroup.
the class MavenProjectLoader method parseMavenPom.
public static MavenProject parseMavenPom(InputStream pomStream, boolean offline) {
MavenEmbedder mavenEmbedder = null;
try {
mavenEmbedder = newMavenEmbedder(offline);
final MavenProject project = mavenEmbedder.readProject(pomStream);
if (IS_FORCE_OFFLINE) {
final Set<Artifact> artifacts = new HashSet<>();
final RepositorySystemSession session = Aether.getAether().getSession();
for (Dependency dep : project.getDependencies()) {
Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getScope(), dep.getType(), dep.getClassifier(), new DefaultArtifactHandler());
if (resolve(session, artifact)) {
artifacts.add(artifact);
} else {
log.error("Artifact can't be resolved {}'", artifact.toString());
}
}
if (!artifacts.isEmpty()) {
project.setArtifacts(artifacts);
}
}
return project;
} catch (Exception e) {
log.error("Unable to create MavenProject from InputStream", e);
throw new RuntimeException(e);
} finally {
if (mavenEmbedder != null) {
mavenEmbedder.dispose();
}
}
}
Aggregations