4

I have a project in which a Maven project is deployed in two different ways using two groupIds and different versions. For example:

a) Depends on a branch (using jitpack):

    <dependency>
        <groupId>com.github.user</groupId>
        <artifactId>myProj</artifactId>
        <version>aaaaaa-SNAPSHOT</version>
    </dependency>

b) Depends on a ... version (other source):

    <dependency>
        <groupId>org.user</groupId>
        <artifactId>myProj</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>

I am using method a). My project also depends on some other project which deploys method b). I don't know, how can I override the b) or how can I tell Maven that these are same project and ask them to use a).

This provides a way to use same project with different artefact names using classifier. I also looked on Dependency Management but could not really understand. I am not an expert in this field.

novice
  • 800
  • 2
  • 11
  • 25
  • Just a hint a `-SNAPSHOT` is not a release... – khmarbaise Jul 14 '17 at 15:15
  • 1
    FYI: "_a) Depends on a branch_" – Maven projects depend on artefacts (`jar`, `war`, etc.), not on (SCM) branches. `aaaaaa-SNAPSHOT` is an unusual version, see [Understanding Maven Version Numbers](https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN8855). "_b) ..._ `1.0.0-SNAPSHOT`" is _not_ a release but a snapshot (i.e. development) version. `jar` and `compile` aren't necessary to be declared explicitely since these are the defaults. – Gerold Broser Jul 14 '17 at 20:27

1 Answers1

4

With respect to Maven, the two dependencies are different and hence cannot be overridden.

But you can use exclusions (detailed description in Optional Dependencies and Dependency Exclusions) to remove any transitive dependency.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Subir Kumar Sao
  • 8,171
  • 3
  • 26
  • 47
  • hmmm.. possibly right. I can use `exclusion` for the method b). If, I am not wrong, it would work if I use version 1.1.0 and exclude 1.0.0. Right? But, I want to completely ignore 1.0.0-SNAPSHOT. Probably, this is not really easy (or not possible at all). – novice Jul 13 '17 at 19:40