0

I am trying to print dependency tree as per dependency:tree for multimodule Maven project and firing the command

mvn org.apache.maven.plugins:maven-dependency-plugin:3.2.0:tree 

works perfectly in this case.

For mentioning additional configurations such as creating aggregate dependency graph and writing to external directory, I made following changes in pom.xml.

<profile> <id>java-src</id> <activation> <activeByDefault>false</activeByDefault> </activation> <build> <plugins> --- --- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>copy-dependencies</id> <phase>compile</phase> <goals> <goal>tree</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> </configuration> </execution> </executions> </plugin> --- --- </plugins> </build> </profile> 

On running mvn tree, it is not working as expected and gives following error:

[ERROR] Unknown lifecycle phase "tree". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

Kindly help regarding the same.

4
  • try mvn depndency:tree Commented Oct 27, 2021 at 10:39
  • tree is not a phase of any Maven standard lifecycle. Commented Oct 27, 2021 at 21:10
  • 1
    @tgdavies ... without the typo. :) Commented Oct 27, 2021 at 21:12
  • Oops yes, dependency! Commented Oct 27, 2021 at 21:51

1 Answer 1

2

There are two problems with this:

  1. As tgdavies already tried to point out, you need to call mvn dependency:tree.
  2. You defined the configuration in an execution bound to the compile phase. This means that the usual build (like mvn clean package) will create the dependency tree, but the configuration is not directly usable from command line. While you can call such an execution from command line by using @-notation, it is more advisable to move the configuration out of the execution block so that it can be used by vanilla calls to mvn dependency:tree.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.