use of org.apache.maven.artifact.DefaultArtifact 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.DefaultArtifact 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.DefaultArtifact in project maven-dependency-plugin by apache.
the class TestDependencyUtil method testFileNameClassifierWithFile.
public void testFileNameClassifierWithFile() throws MojoExecutionException {
// specifically testing the default operation that getFormattedFileName
// returns
// the actual name of the file if available unless remove version is
// set.
ArtifactHandler ah = new DefaultArtifactHandlerStub("war", "sources");
VersionRange vr = VersionRange.createFromVersion("1.1-SNAPSHOT");
Artifact artifact = new DefaultArtifact("test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "sources", ah, false);
File file = new File("/target", "test-file-name.jar");
artifact.setFile(file);
String name = DependencyUtil.getFormattedFileName(artifact, false);
String expectedResult = "two-1.1-SNAPSHOT-sources.war";
assertEquals(expectedResult, name);
name = DependencyUtil.getFormattedFileName(artifact, false, false, false, true);
expectedResult = "two-1.1-SNAPSHOT.war";
assertEquals(expectedResult, name);
name = DependencyUtil.getFormattedFileName(artifact, true);
expectedResult = "two-sources.war";
assertEquals(expectedResult, name);
artifact = new DefaultArtifact("test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false);
name = DependencyUtil.getFormattedFileName(artifact, true);
expectedResult = "two.war";
assertEquals(expectedResult, name);
// test that we pickup the correct extension in the file name if set.
ah = new DefaultArtifactHandlerStub("jar", null);
artifact = new DefaultArtifact("test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false);
name = DependencyUtil.getFormattedFileName(artifact, true);
expectedResult = "two.jar";
assertEquals(expectedResult, name);
}
use of org.apache.maven.artifact.DefaultArtifact in project maven-dependency-plugin by apache.
the class TestDependencyUtil method testFileNameClassifier.
public void testFileNameClassifier() throws MojoExecutionException {
ArtifactHandler ah = new DefaultArtifactHandlerStub("jar", "sources");
VersionRange vr = VersionRange.createFromVersion("1.1-SNAPSHOT");
Artifact artifact = new DefaultArtifact("test", "two", vr, Artifact.SCOPE_PROVIDED, "jar", "sources", ah, false);
String name = DependencyUtil.getFormattedFileName(artifact, false);
String expectedResult = "two-1.1-SNAPSHOT-sources.jar";
assertEquals(expectedResult, name);
name = DependencyUtil.getFormattedFileName(artifact, true);
expectedResult = "two-sources.jar";
assertEquals(expectedResult, name);
name = DependencyUtil.getFormattedFileName(artifact, false, false, false, true);
expectedResult = "two-1.1-SNAPSHOT.jar";
assertEquals(expectedResult, name);
ah = new DefaultArtifactHandlerStub("war", null);
artifact = new DefaultArtifact("test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false);
name = DependencyUtil.getFormattedFileName(artifact, true);
expectedResult = "two.war";
assertEquals(expectedResult, name);
}
use of org.apache.maven.artifact.DefaultArtifact in project fabric8-maven-plugin by fabric8io.
the class AbstractSpringBootHealthCheckEnricherSupport method init.
@Before
public void init() {
String version = getSpringBootVersion();
this.propertyHelper = new SpringBootConfigurationHelper(version);
final MavenProject project = new MavenProject();
Set<Artifact> artifacts = new HashSet<>();
Artifact a = new DefaultArtifact("org.springframework.boot", "spring-boot", version, "compile", "jar", "", null);
a.setResolved(true);
artifacts.add(a);
project.setArtifacts(artifacts);
new Expectations() {
{
context.getProject();
result = project;
}
};
}
Aggregations