1

In my parent pom xml file I have declared some dependencies that are used in most of the children's poms.

However, in one child pom, I don't use these dependencies and I want to find a way in order to exclude them (in order not to be seen as unused dependencies).

Right now, in de dependencies section of child pom I have nothing! Any ideas?

  • is the way to go if you want to exclude specific dependencies from any pom.xml file, though you would have to explain further, if this is not what you are looking for. https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html – JCompetence Dec 14 '20 at 11:35
  • 1
    @SusanMustafa This does not work for dependencies inherited from the parent. – J Fabian Meier Dec 14 '20 at 11:42

1 Answers1

0

AFAIK there is no way to exclude them.

You can, though, define exceptions in the maven dependency plugin so that they do not appear as "unused". For that, see

http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • I ve tried to add in the child pom in the maven dependency plugin the list of the dependencies that I want to not appear as unused declared dependencies but without success. I ve tried https://maven.apache.org/plugins/maven-dependency-plugin/examples/exclude-dependencies-from-dependency-analysis.html – Costi Peticilă Dec 14 '20 at 12:19
  • Then you probably made some syntax error. – J Fabian Meier Dec 14 '20 at 12:21
  • The syntax looks good but I don't know if this is supposed to work with dependencies declared in the parent pom. – Costi Peticilă Dec 14 '20 at 13:15
  • I don't think that it makes a difference whether you declare it in the parent or in the POM itself. – J Fabian Meier Dec 14 '20 at 13:45