Yesterday, during the explanation of the roadmap of maven 2.1 in the meeting "Maven day", Jason said that a new setting will be supported to exclude all the transitive dependencies.  I had effectively see numerous users that were complaining about the big exclusion list they have to maintain which is as annoying as in m1 for the list of all the dependencies.
  My question : Is there someone who proposed to add a list of profiles (We can use this term because we already use it in m2 but I don't have another idea today) in a dependency.

  For example for a complex librairie like Spring we can ask them to create as many POM as they have usecases of this library. But it will be difficult to maintain.
  Or we could do something like :
In the POM of MyHorribleProjectWithALotOfOptionalDependencies

<project>
  ...
   <dependencies>
    <dependency>
      <groupId>grp-A</groupId>
      <artifactId>lib-A</artifactId>
      <optional>true</optional>
      <profiles>
        <profile>profile-1</profile>
      </profiles>
    </dependency>
    <dependency>
      <groupId>grp-B</groupId>
      <artifactId>lib-B</artifactId>
      <optional>true</optional>
      <profiles>
        <profile>profile-2</profile>
      </profiles>
    </dependency>
    <dependency>
      <groupId>grp-C</groupId>
      <artifactId>lib-C</artifactId>
      <optional>true</optional>
      <profiles>
        <profile>profile-1</profile>
        <profile>profile-2</profile>
      </profiles>
    </dependency>
    <dependency>
      <groupId>grp-D</groupId>
      <artifactId>lib-D</artifactId>
    </dependency>
  </dependencies>
...
</project>

It's something more fine than the optional element.

In the POM of my project which uses this framework, I can use the dependency without profile :

 <dependency>
 <groupId>MyHorribleProjectWithALotOfOptionalDependencies</groupId>
 <artifactId>MyHorribleProjectWithALotOfOptionalDependencies</artifactId>
 </dependency>

To get all the dependencies.

I can use the profile-1

 <dependency>
 <groupId>MyHorribleProjectWithALotOfOptionalDependencies</groupId>
 <artifactId>MyHorribleProjectWithALotOfOptionalDependencies</artifactId>
 <profile>profile-1</profile>
 </dependency>

To get lib-A, lib-C, lib-D

I can use the profile-2 to get lib-B, lib-C, lib-D

  • No labels