use of org.apache.maven.plugins.dependency.tree.TreeMojo in project maven-plugins by apache.
the class TestTreeMojo method runTreeMojo.
/**
* Help finding content in the given list of string
*
* @param outputFile the outputFile.
* @param format The format.
* @throws Exception in case of an error.
* @return list of strings in the output file
*/
private List<String> runTreeMojo(String outputFile, String format) throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml");
String outputFileName = testDir.getAbsolutePath() + outputFile;
TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom);
setVariableValueToObject(mojo, "outputType", format);
setVariableValueToObject(mojo, "outputFile", new File(outputFileName));
assertNotNull(mojo);
assertNotNull(mojo.getProject());
MavenProject project = mojo.getProject();
project.setArtifact(this.stubFactory.createArtifact("testGroupId", "project", "1.0"));
Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
artifacts.addAll(directArtifacts);
project.setArtifacts(artifacts);
project.setDependencyArtifacts(directArtifacts);
mojo.execute();
BufferedReader fp1 = new BufferedReader(new FileReader(outputFileName));
List<String> contents = new ArrayList<String>();
String line;
while ((line = fp1.readLine()) != null) {
contents.add(line);
}
fp1.close();
return contents;
}
use of org.apache.maven.plugins.dependency.tree.TreeMojo in project maven-plugins by apache.
the class TestTreeMojo method _testTreeTestEnvironment.
/**
* Tests the proper discovery and configuration of the mojo.
*
* @throws Exception in case of an error.
*/
public void _testTreeTestEnvironment() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml");
TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom);
assertNotNull(mojo);
assertNotNull(mojo.getProject());
MavenProject project = mojo.getProject();
project.setArtifact(this.stubFactory.createArtifact("testGroupId", "project", "1.0"));
Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
artifacts.addAll(directArtifacts);
project.setArtifacts(artifacts);
project.setDependencyArtifacts(directArtifacts);
mojo.execute();
DependencyNode rootNode = mojo.getDependencyGraph();
assertNodeEquals("testGroupId:project:jar:1.0:compile", rootNode);
assertEquals(2, rootNode.getChildren().size());
assertChildNodeEquals("testGroupId:snapshot:jar:2.0-SNAPSHOT:compile", rootNode, 0);
assertChildNodeEquals("testGroupId:release:jar:1.0:compile", rootNode, 1);
}
use of org.apache.maven.plugins.dependency.tree.TreeMojo in project maven-dependency-plugin by apache.
the class TestTreeMojo method _testTreeTestEnvironment.
/**
* Tests the proper discovery and configuration of the mojo.
*
* @throws Exception in case of an error.
*/
public void _testTreeTestEnvironment() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml");
TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom);
assertNotNull(mojo);
assertNotNull(mojo.getProject());
MavenProject project = mojo.getProject();
project.setArtifact(this.stubFactory.createArtifact("testGroupId", "project", "1.0"));
Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
artifacts.addAll(directArtifacts);
project.setArtifacts(artifacts);
project.setDependencyArtifacts(directArtifacts);
mojo.execute();
DependencyNode rootNode = mojo.getDependencyGraph();
assertNodeEquals("testGroupId:project:jar:1.0:compile", rootNode);
assertEquals(2, rootNode.getChildren().size());
assertChildNodeEquals("testGroupId:snapshot:jar:2.0-SNAPSHOT:compile", rootNode, 0);
assertChildNodeEquals("testGroupId:release:jar:1.0:compile", rootNode, 1);
}
use of org.apache.maven.plugins.dependency.tree.TreeMojo in project maven-dependency-plugin by apache.
the class TestTreeMojo method runTreeMojo.
/**
* Help finding content in the given list of string
*
* @param outputFile the outputFile.
* @param format The format.
* @throws Exception in case of an error.
* @return list of strings in the output file
*/
private List<String> runTreeMojo(String outputFile, String format) throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml");
String outputFileName = testDir.getAbsolutePath() + outputFile;
TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom);
setVariableValueToObject(mojo, "outputType", format);
setVariableValueToObject(mojo, "outputFile", new File(outputFileName));
assertNotNull(mojo);
assertNotNull(mojo.getProject());
MavenProject project = mojo.getProject();
project.setArtifact(this.stubFactory.createArtifact("testGroupId", "project", "1.0"));
Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
artifacts.addAll(directArtifacts);
project.setArtifacts(artifacts);
project.setDependencyArtifacts(directArtifacts);
mojo.execute();
BufferedReader fp1 = new BufferedReader(new FileReader(outputFileName));
List<String> contents = new ArrayList<String>();
String line;
while ((line = fp1.readLine()) != null) {
contents.add(line);
}
fp1.close();
return contents;
}
Aggregations