use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project maven-plugins by apache.
the class ResolutionManagementInfoTest method testAddMultiArtifactWithReplacemen.
public void testAddMultiArtifactWithReplacemen() throws Exception {
ResolutionManagementInfo rmi = new ResolutionManagementInfo(new MavenProject());
Artifact a1 = new DefaultArtifact("groupid", "a1", VersionRange.createFromVersion("1.0"), "test", "jar", null, new DefaultArtifactHandler());
Artifact a2 = new DefaultArtifact("groupid", "a2", VersionRange.createFromVersion("1.0"), "test", "jar", null, new DefaultArtifactHandler());
Artifact a3 = new DefaultArtifact("groupid", "a3", VersionRange.createFromVersion("1.0"), "test", "jar", null, new DefaultArtifactHandler());
rmi.addArtifacts(new HashSet<Artifact>(Arrays.asList(a1, a2, a3)));
Artifact b2 = new DefaultArtifact("groupid", "a2", VersionRange.createFromVersion("1.0"), "compile", "jar", null, new DefaultArtifactHandler());
Artifact b3 = new DefaultArtifact("groupid", "a3", VersionRange.createFromVersion("1.0"), "compile", "jar", null, new DefaultArtifactHandler());
rmi.addArtifacts(new HashSet<Artifact>(Arrays.asList(b2, b3)));
assertEquals(3, rmi.getArtifacts().size());
int compile = 0;
int test = 0;
for (Artifact artifact : rmi.getArtifacts()) {
if (Artifact.SCOPE_COMPILE.equals(artifact.getScope())) {
compile++;
} else {
test++;
}
}
assertEquals(2, compile);
assertEquals(1, test);
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project bnd by bndtools.
the class IndexerMojo method attach.
private void attach(File file, String type, String extension) {
DefaultArtifactHandler handler = new DefaultArtifactHandler(type);
handler.setExtension(extension);
DefaultArtifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), null, type, null, handler);
artifact.setFile(file);
project.addAttachedArtifact(artifact);
}
Aggregations