use of org.apache.maven.artifact.handler.DefaultArtifactHandler 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();
}
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project felix by apache.
the class BundleAllPluginTest method testNoReBundling.
public void testNoReBundling() throws Exception {
File testFile = getTestFile("target/test-classes/org.apache.maven.maven-model_1.0.0.0.jar");
if (testFile.exists()) {
testFile.delete();
}
VersionRange versionRange = VersionRange.createFromVersion("1.0.0.0");
ArtifactHandler artifactHandler = new DefaultArtifactHandler("jar");
Artifact artifact = new DefaultArtifact("group", "artifact", versionRange, null, "jar", null, artifactHandler);
MavenProject project = getMavenProjectStub();
project.setGroupId(artifact.getGroupId());
project.setArtifactId(artifact.getArtifactId());
project.setVersion(artifact.getVersion());
project.setArtifact(artifact);
project.setArtifacts(Collections.EMPTY_SET);
project.setDependencyArtifacts(Collections.EMPTY_SET);
File bundleFile = getTestFile("src/test/resources/org.apache.maven.maven-model_2.1.0.SNAPSHOT.jar");
artifact.setFile(bundleFile);
BundleInfo bundleInfo = plugin.bundle(project);
Map exports = bundleInfo.getExportedPackages();
String[] packages = new String[] { "org.apache.maven.model.io.jdom", "org.apache.maven.model" };
for (int i = 0; i < packages.length; i++) {
assertTrue("Bundle info does not contain a package that it is exported in the manifest: " + packages[i], exports.containsKey(packages[i]));
}
assertFalse("Bundle info contains a package that it is not exported in the manifest", exports.containsKey("org.apache.maven.model.io.xpp3"));
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project maven-dependency-plugin by apache.
the class TestSourcesMarkerFileHandler method setUp.
protected void setUp() throws Exception {
super.setUp();
ArtifactHandler ah = new DefaultArtifactHandler();
VersionRange vr = VersionRange.createFromVersion("1.1");
Artifact artifact = new DefaultArtifact("test", "1", vr, Artifact.SCOPE_COMPILE, "jar", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "2", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "3", vr, Artifact.SCOPE_TEST, "sources", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "4", vr, Artifact.SCOPE_RUNTIME, "zip", "", ah, false);
artifacts.add(artifact);
// pick random output location
Random a = new Random();
outputFolder = new File("target/markers" + a.nextLong() + "/");
outputFolder.delete();
assertFalse(outputFolder.exists());
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project maven-dependency-plugin by apache.
the class TestDefaultMarkerFileHandler method setUp.
protected void setUp() throws Exception {
super.setUp();
ArtifactHandler ah = new DefaultArtifactHandler();
VersionRange vr = VersionRange.createFromVersion("1.1");
Artifact artifact = new DefaultArtifact("test", "1", vr, Artifact.SCOPE_COMPILE, "jar", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "2", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "3", vr, Artifact.SCOPE_TEST, "sources", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "4", vr, Artifact.SCOPE_RUNTIME, "zip", "", ah, false);
artifacts.add(artifact);
outputFolder = new File("target/markers/");
DependencyTestUtils.removeDirectory(this.outputFolder);
assertFalse(outputFolder.exists());
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project fabric8-maven-plugin by fabric8io.
the class DependencyEnricherTest method getDummyArtifacts.
private Set<Artifact> getDummyArtifacts() {
Set<Artifact> artifacts = new TreeSet<>();
Artifact artifact = new DefaultArtifact("io.fabric8.tenant.apps", "jenkins", "1.0.0-SNAPSHOT", "compile", "jar", null, new DefaultArtifactHandler("jar"));
File aFile = new File(getClass().getResource(artifactFilePath).getFile());
artifact.setFile(aFile);
artifacts.add(artifact);
return artifacts;
}
Aggregations