Search in sources :

Example 31 with DefaultArtifact

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);
        }
    }
}
Also used : DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) Dependency(org.apache.maven.model.Dependency) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 32 with DefaultArtifact

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;
}
Also used : ArtifactRepositoryLayout(org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) LegacyRepositoryLayout(org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout) VersionRange(org.apache.maven.artifact.versioning.VersionRange) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) ProjectBuilderConfiguration(org.apache.maven.project.ProjectBuilderConfiguration) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) MavenProjectStub(org.apache.maven.plugin.testing.stubs.MavenProjectStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 33 with DefaultArtifact

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);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) DefaultArtifactHandlerStub(org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub) VersionRange(org.apache.maven.artifact.versioning.VersionRange) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 34 with DefaultArtifact

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);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) DefaultArtifactHandlerStub(org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub) VersionRange(org.apache.maven.artifact.versioning.VersionRange) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 35 with DefaultArtifact

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;
        }
    };
}
Also used : Expectations(mockit.Expectations) SpringBootConfigurationHelper(io.fabric8.maven.core.util.SpringBootConfigurationHelper) MavenProject(org.apache.maven.project.MavenProject) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Before(org.junit.Before)

Aggregations

DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)51 Artifact (org.apache.maven.artifact.Artifact)35 File (java.io.File)26 DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)26 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)22 VersionRange (org.apache.maven.artifact.versioning.VersionRange)17 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)10 DefaultArtifactHandlerStub (org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub)10 MavenProject (org.apache.maven.project.MavenProject)9 MavenProjectResourcesStub (org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub)7 ArrayList (java.util.ArrayList)4 Random (java.util.Random)4 InputStream (java.io.InputStream)3 List (java.util.List)3 Map (java.util.Map)3 DefaultArtifactRepository (org.apache.maven.artifact.repository.DefaultArtifactRepository)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2