Search in sources :

Example 26 with ArtifactHandler

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);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) DefaultArtifactHandlerStub(org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub) VersionRange(org.apache.maven.artifact.versioning.VersionRange) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 27 with ArtifactHandler

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());
}
Also used : DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) Random(java.util.Random) VersionRange(org.apache.maven.artifact.versioning.VersionRange) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 28 with ArtifactHandler

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);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub)

Example 29 with ArtifactHandler

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" });
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub)

Example 30 with ArtifactHandler

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" });
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub)

Aggregations

ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)35 File (java.io.File)17 Artifact (org.apache.maven.artifact.Artifact)14 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)12 JarArtifactStub (org.apache.maven.plugins.war.stub.JarArtifactStub)10 ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)9 VersionRange (org.apache.maven.artifact.versioning.VersionRange)7 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)6 DefaultArtifactHandlerStub (org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub)5 AarArtifactStub (org.apache.maven.plugins.war.stub.AarArtifactStub)5 EJBArtifactStub (org.apache.maven.plugins.war.stub.EJBArtifactStub)5 EJBClientArtifactStub (org.apache.maven.plugins.war.stub.EJBClientArtifactStub)5 IncludeExcludeWarArtifactStub (org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)5 MarArtifactStub (org.apache.maven.plugins.war.stub.MarArtifactStub)5 PARArtifactStub (org.apache.maven.plugins.war.stub.PARArtifactStub)5 TLDArtifactStub (org.apache.maven.plugins.war.stub.TLDArtifactStub)5 WarArtifactStub (org.apache.maven.plugins.war.stub.WarArtifactStub)5 XarArtifactStub (org.apache.maven.plugins.war.stub.XarArtifactStub)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 MavenProject (org.apache.maven.project.MavenProject)4