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;
}
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;
}
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;
}
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));
}
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();
}
}
Aggregations