Exclude dependency in a profile

后端 未结 6 1853
别那么骄傲
别那么骄傲 2021-02-06 23:49

I have a maven module which has some dependencies. In a certain profile, I want to exclude some of those dependencies (to be exact, all dependencies with a certain group id). Th

6条回答
  •  梦如初夏
    2021-02-07 00:28

    To my knowledge, no, you can't deactivate dependencies (you can exclude transitive dependencies but this is not what you are asking for) and yes, what you are currently doing with the POM (manually editing it) is wrong.

    So, instead of removing dependencies, you should put them in a profile and either:

    • Option #1: use the profile when required or
    • Option #2: mark the profile as activated by default or put it in the list of active profiles and deactivate it when required.

    A third option would be (not profile based):

    • Option #3: separate things in two separated modules (as you have separated concerns) and use inheritance.

提交回复
热议问题