Search in sources :

Example 1 with ArtifactHandler

use of org.apache.maven.artifact.handler.ArtifactHandler in project che by eclipse.

the class MavenModelUtil method convertExtension.

private static String convertExtension(Artifact artifact) {
    ArtifactHandler artifactHandler = artifact.getArtifactHandler();
    String result = null;
    if (artifactHandler != null) {
        result = artifactHandler.getExtension();
    }
    if (result == null) {
        result = artifact.getType();
    }
    return result;
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler)

Example 2 with ArtifactHandler

use of org.apache.maven.artifact.handler.ArtifactHandler in project intellij-community by JetBrains.

the class Maven2ModelConverter method convertExtension.

private static String convertExtension(Artifact artifact) {
    ArtifactHandler handler = artifact.getArtifactHandler();
    String result = null;
    if (handler != null)
        result = handler.getExtension();
    if (result == null)
        result = artifact.getType();
    return result;
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler)

Example 3 with ArtifactHandler

use of org.apache.maven.artifact.handler.ArtifactHandler in project intellij-community by JetBrains.

the class MavenModelConverter method convertExtension.

private static String convertExtension(Artifact artifact) {
    ArtifactHandler handler = artifact.getArtifactHandler();
    String result = null;
    if (handler != null)
        result = handler.getExtension();
    if (result == null)
        result = artifact.getType();
    return result;
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler)

Example 4 with ArtifactHandler

use of org.apache.maven.artifact.handler.ArtifactHandler in project maven-plugins by apache.

the class TestAbstractFileNameMapping method test.

@Test
public void test() {
    ArtifactHandler handler = mock(ArtifactHandler.class);
    when(handler.getExtension()).thenReturn("jar");
    Artifact artifact = mock(Artifact.class);
    when(artifact.getArtifactHandler()).thenReturn(handler);
    when(artifact.getArtifactId()).thenReturn("mear149");
    when(artifact.getVersion()).thenReturn("1.0-SNAPSHOT");
    when(artifact.getBaseVersion()).thenReturn("1.0-20130423.042904");
    // default behavior: use -SNAPSHOT
    assertEquals("mear149-1.0-SNAPSHOT.jar", abstractFileNameMapping.generateFileName(artifact, true));
    abstractFileNameMapping.setUseBaseVersion(true);
    assertEquals("mear149-1.0-20130423.042904.jar", abstractFileNameMapping.generateFileName(artifact, true));
    abstractFileNameMapping.setUseBaseVersion(false);
    assertEquals("mear149-1.0-SNAPSHOT.jar", abstractFileNameMapping.generateFileName(artifact, true));
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) Artifact(org.apache.maven.artifact.Artifact) Test(org.junit.Test)

Example 5 with ArtifactHandler

use of org.apache.maven.artifact.handler.ArtifactHandler in project felix by apache.

the class BlueprintComponentTest method test.

protected void test(String mode) throws Exception {
    MavenProjectStub project = new MavenProjectStub() {

        private final List resources = new ArrayList();

        @Override
        public void addResource(Resource resource) {
            resources.add(resource);
        }

        @Override
        public List getResources() {
            return resources;
        }

        @Override
        public File getBasedir() {
            return new File("target/tmp/basedir");
        }
    };
    project.setGroupId("group");
    project.setArtifactId("artifact");
    project.setVersion("1.1.0.0");
    VersionRange versionRange = VersionRange.createFromVersion(project.getVersion());
    ArtifactHandler artifactHandler = new DefaultArtifactHandler("jar");
    Artifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), versionRange, null, "jar", null, artifactHandler);
    project.setArtifact(artifact);
    ProjectBuilderConfiguration projectBuilderConfiguration = new DefaultProjectBuilderConfiguration();
    projectBuilderConfiguration.setLocalRepository(null);
    project.setProjectBuilderConfiguration(projectBuilderConfiguration);
    Resource r = new Resource();
    r.setDirectory(new File("src/test/resources").getAbsoluteFile().getCanonicalPath());
    r.setIncludes(Arrays.asList("**/*.*"));
    project.addResource(r);
    project.addCompileSourceRoot(new File("src/test/resources").getAbsoluteFile().getCanonicalPath());
    ManifestPlugin plugin = new ManifestPlugin();
    plugin.setBuildDirectory("target/tmp/basedir/target");
    plugin.setOutputDirectory(new File("target/tmp/basedir/target/classes"));
    setVariableValueToObject(plugin, "m_dependencyGraphBuilder", lookup(DependencyGraphBuilder.class.getName(), "default"));
    Map instructions = new HashMap();
    instructions.put("service_mode", mode);
    instructions.put("Test", "Foo");
    instructions.put("nsh_interface", "foo.bar.Namespace");
    instructions.put("nsh_namespace", "ns");
    instructions.put("Export-Service", "p7.Foo;mk=mv");
    instructions.put("Import-Service", "org.osgi.service.cm.ConfigurationAdmin;availability:=optional");
    Properties props = new Properties();
    DependencyNode dependencyGraph = plugin.buildDependencyGraph(project);
    Builder builder = plugin.buildOSGiBundle(project, dependencyGraph, instructions, props, plugin.getClasspath(project, dependencyGraph));
    Manifest manifest = builder.getJar().getManifest();
    String impSvc = manifest.getMainAttributes().getValue(Constants.IMPORT_SERVICE);
    if ("service".equals(mode)) {
        String expSvc = manifest.getMainAttributes().getValue(Constants.EXPORT_SERVICE);
        assertNotNull(expSvc);
        assertTrue(expSvc.contains("beanRef.Foo;osgi.service.blueprint.compname=myBean"));
    } else {
        String prvCap = manifest.getMainAttributes().getValue(Constants.PROVIDE_CAPABILITY);
        assertNotNull(prvCap);
        assertTrue(prvCap.contains("osgi.service;effective:=active;objectClass=\"beanRef.Foo\";osgi.service.blueprint.compname=myBean"));
    }
    assertNotNull(impSvc);
    String impPkg = manifest.getMainAttributes().getValue(Constants.IMPORT_PACKAGE);
    List<String> pkgs = Create.list();
    for (Clause clause : Parser.parseHeader(impPkg)) {
        pkgs.add(clause.getName());
    }
    for (int i = 1; i <= 14; i++) {
        assertTrue(pkgs.contains("p" + i));
    }
    try (Verifier verifier = new Verifier(builder)) {
        verifier.verify();
    }
}
Also used : HashMap(java.util.HashMap) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) DependencyGraphBuilder(org.apache.maven.shared.dependency.graph.DependencyGraphBuilder) Builder(aQute.bnd.osgi.Builder) ArrayList(java.util.ArrayList) Resource(org.apache.maven.model.Resource) VersionRange(org.apache.maven.artifact.versioning.VersionRange) Properties(java.util.Properties) Manifest(java.util.jar.Manifest) Verifier(aQute.bnd.osgi.Verifier) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) ProjectBuilderConfiguration(org.apache.maven.project.ProjectBuilderConfiguration) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) MavenProjectStub(org.apache.maven.plugin.testing.stubs.MavenProjectStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) DependencyNode(org.apache.maven.shared.dependency.graph.DependencyNode) ArrayList(java.util.ArrayList) List(java.util.List) Clause(org.apache.felix.utils.manifest.Clause) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Aggregations

ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)51 File (java.io.File)26 Artifact (org.apache.maven.artifact.Artifact)26 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)23 VersionRange (org.apache.maven.artifact.versioning.VersionRange)17 DefaultArtifactHandlerStub (org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub)10 JarArtifactStub (org.apache.maven.plugins.war.stub.JarArtifactStub)10 ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)9 DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)6 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)6 MavenProject (org.apache.maven.project.MavenProject)6 DefaultArtifactCoordinate (org.apache.maven.shared.artifact.DefaultArtifactCoordinate)6 ArrayList (java.util.ArrayList)5 Random (java.util.Random)4 AarArtifactStub (org.apache.maven.plugins.war.stub.AarArtifactStub)4 EJBArtifactStub (org.apache.maven.plugins.war.stub.EJBArtifactStub)4 EJBClientArtifactStub (org.apache.maven.plugins.war.stub.EJBClientArtifactStub)4 IncludeExcludeWarArtifactStub (org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)4 MarArtifactStub (org.apache.maven.plugins.war.stub.MarArtifactStub)4