Ran into this also recently (again).

I believe a good way to solve this would be to allow overriding a dependency
inherited from the parent POM with `<scope>none</scope>` or something like that.

I tried overriding with `<scope>provided</scope>` but for some reason that 
didn't seem to work.

The context was trying that I typically have `slf4j-simple` as a test 
dependency for all
modules so I had added that to the parent, but then I had one module where I 
absolutely
needed to use the log4j SLF4J binding and I couldn't get rid of the 
`slf4j-simple` then
just for that module.

That said, in general I would advise against inheriting dependencies from 
parents.
Typically, you inherit too much and that means you'll have to add excludes for 
the
dependency analyzer plugin as well... it's a mess.

-- Richard

> On 25. Sep 2024, at 17:17, Xeno Amess <xenoam...@gmail.com> wrote:
> 
> and another idea be we could add a <exclusions> and <exclusionManagement>
> (kind of mirror to dependencies and dependencyManagement) to remove those
> dependencies from parent &EVERY dependency...
> 
> Xeno Amess <xenoam...@gmail.com> 于2024年9月25日周三 22:59写道:
> 
>> Hi.
>> 
>> In maven3 we cannot exclude dependencies inherited from parent.
>> 
>> see this
>> 
>> https://stackoverflow.com/questions/2681759/is-there-anyway-to-exclude-artifacts-inherited-from-a-parent-pom
>> 
>> That be kind of annoying if situation comes to be the parent-pom be
>> maintained by others, and you extend it and it works fine until one day
>> they suddenlly decide to depend on some packages you would never make
>> compatible/useless, and you have no permission to change their mind.
>> What I wanna do is adding such a gramma like this:
>> 
>> <parent>
>>  <artifactId>base</artifactId>
>>  <groupId>es.uniovi.innova</groupId>
>>  <version>1.0.0</version>
>>  <exclusions>
>>    <exclusion>
>>      <groupId>javax.mail</groupId>
>>      <artifactId>mail</artifactId>
>>    </exclusion>
>>  </exclusions>
>> </parent>
>> 
>> '
>> but I wanna hear about your opinions first.
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to