Reputation: 62632
I have several independent projects (they don't have the same parent) but they use the same set of libraries. For example
All these projects use Spring, Postgres, Hibrenate and tomcat. What I want to do is introduce the concept of a named collection of dependecies somethnig along the following lines:
I want to be able to say something like Project A depends on TSHP 1.0, Project B depends on TSHP 2.0 ... etc. The value I see for this type of setup is
Can this type of setup be done with maven3? If so How?
Update: The problem I see with the parent pom setup is that there can only be one parent for a POM, but I might have several standard named class-paths, for example:
Upvotes: 3
Views: 148
Reputation: 9651
Create a new project for the 'platform', i.e. the group of dependencies that you want to use together. Its packaging type should be: pom
.
<project>
<groupId>…</groupId>
<artifactId>tshp-platform</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<dependencies>
<!-- Dependencies for TSHP 1.0 -->
</dependencies>
…
Release 1.0 of the the pom. Then update the version and dependencies for TSHP 2.0. Then release that.
Now your projects can simply declare a dependency on the pom project, and will pick up the platform transitively.
However, note that it's often considered good practice to explicitly declare artifacts that each individual project directly depends on. However, that's not essential.
Upvotes: 2
Reputation: 4375
I think what you are talking about is the concept of "Corporate POM".
The definition given by Sonatype is :
A Corporate Pom is a Parent Pom that sits at the top of an inheritance structure for a corporation. This is a recommended best practice for centralizing certain configuration such as Enforcer rule configuration, default Plugin versions, etc. This may also be called an “Organizational Pom.” The term “Super Pom” is often mis-applied to Corporate Poms.
See also :
A parent pom is simply a pom from which other poms inherit via a section. Poms that inherit from a parent are sometimes referred to as “children” or “child poms.”
Upvotes: 1