use of org.apache.maven.artifact.handler.ArtifactHandler in project maven-plugins 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);
}
use of org.apache.maven.artifact.handler.ArtifactHandler in project maven-plugins 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.ArtifactHandler in project maven-plugins by apache.
the class WarDependenciesAnalysisTest method testRemovedDependency.
public void testRemovedDependency() throws Exception {
// setup test data
final String testId = "remove-dependency";
final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact.setArtifactId("lib-test");
jarArtifact.setVersion("1.0");
doTestTwiceWithUpdatedDependency(testId, new ArtifactStub[] { jarArtifact }, null, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, null);
}
use of org.apache.maven.artifact.handler.ArtifactHandler in project maven-plugins by apache.
the class WarDependenciesAnalysisTest method testDependencyWithUpdatedVersion.
public void testDependencyWithUpdatedVersion() throws Exception {
// setup test data
final String testId = "dependency-update-version";
final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact.setArtifactId("lib-test");
jarArtifact.setVersion("1.0");
ArtifactStub jarArtifact2 = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact2.setArtifactId("lib-test");
jarArtifact2.setVersion("2.0");
doTestTwiceWithUpdatedDependency(testId, new ArtifactStub[] { jarArtifact }, new ArtifactStub[] { jarArtifact2 }, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, new String[] { "WEB-INF/lib/lib-test-2.0.jar" });
}
use of org.apache.maven.artifact.handler.ArtifactHandler in project maven-plugins by apache.
the class WarDependenciesAnalysisTest method testNoChange.
public void testNoChange() throws Exception {
// setup test data
final String testId = "no-change";
final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact.setArtifactId("lib-test");
jarArtifact.setVersion("1.0");
doTestTwiceWithUpdatedDependency(testId, new ArtifactStub[] { jarArtifact }, new ArtifactStub[] { jarArtifact }, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, new String[] { "WEB-INF/lib/lib-test-1.0.jar" });
}
Aggregations