Search in sources :

Example 1 with CollectDependenciesMojo

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

the class TestCollectMojo method testCollectTestEnvironment.

/**
     * tests the proper discovery and configuration of the mojo
     * 
     * @throws Exception if a problem occurs
     */
public void testCollectTestEnvironment() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml");
    CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", 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());
}
Also used : CollectDependenciesMojo(org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo) MavenProject(org.apache.maven.project.MavenProject) DependencyStatusSets(org.apache.maven.plugins.dependency.utils.DependencyStatusSets) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 2 with CollectDependenciesMojo

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

the class TestCollectMojo method testSilent.

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

Example 3 with CollectDependenciesMojo

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

the class TestCollectMojo method testCollectTestEnvironment_excludeTransitive.

/**
     * tests the proper discovery and configuration of the mojo
     *
     * @throws Exception if a problem occurs
     */
public void testCollectTestEnvironment_excludeTransitive() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml");
    CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", 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);
    setVariableValueToObject(mojo, "excludeTransitive", Boolean.TRUE);
    mojo.execute();
    DependencyStatusSets results = mojo.getResults();
    assertNotNull(results);
    assertEquals(directArtifacts.size(), results.getResolvedDependencies().size());
}
Also used : CollectDependenciesMojo(org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo) MavenProject(org.apache.maven.project.MavenProject) DependencyStatusSets(org.apache.maven.plugins.dependency.utils.DependencyStatusSets) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

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