Search in sources :

Example 1 with ResolveDependenciesMojo

use of org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo in project maven-plugins by apache.

the class TestResolveMojo method testresolveTestEnvironment.

/**
     * tests the proper discovery and configuration of the mojo
     * 
     * @throws Exception
     */
public void testresolveTestEnvironment() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml");
    ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom);
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    MavenProject project = mojo.getProject();
    mojo.setSilent(true);
    Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
    Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
    artifacts.addAll(directArtifacts);
    project.setArtifacts(artifacts);
    project.setDependencyArtifacts(directArtifacts);
    mojo.execute();
    DependencyStatusSets results = mojo.getResults();
    assertNotNull(results);
    assertEquals(artifacts.size(), results.getResolvedDependencies().size());
    setVariableValueToObject(mojo, "excludeTransitive", Boolean.TRUE);
    mojo.execute();
    results = mojo.getResults();
    assertNotNull(results);
    assertEquals(directArtifacts.size(), results.getResolvedDependencies().size());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ResolveDependenciesMojo(org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo) DependencyStatusSets(org.apache.maven.plugins.dependency.utils.DependencyStatusSets) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 2 with ResolveDependenciesMojo

use of org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo in project maven-plugins by apache.

the class TestResolveMojo method testSilent.

public void testSilent() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml");
    ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom);
    mojo.setSilent(false);
    assertFalse(mojo.getLog() instanceof SilentLog);
}
Also used : SilentLog(org.apache.maven.plugin.testing.SilentLog) ResolveDependenciesMojo(org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo) File(java.io.File)

Aggregations

File (java.io.File)2 ResolveDependenciesMojo (org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo)2 Artifact (org.apache.maven.artifact.Artifact)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1 DependencyStatusSets (org.apache.maven.plugins.dependency.utils.DependencyStatusSets)1 MavenProject (org.apache.maven.project.MavenProject)1