I have a multi module project (flat structure) as follows
parentpom (1.1-SNAPSHOT) moduleA (inherits parentpom version, depends on moduleB(1.1-SNAPSHOT)) moduleB (inherits parentpom version) aggregat开发者_开发知识库or (inherits parentpom version, aggregates moduleA, moduleB)
The aggregator allows me to build, install and deploy moduleA and moduleB at the same time, and appears to do what I expect.
When I try and do a release of version 1.1, I can't because moduleA depends on moduleB(1.1-SNAPSHOT), resulting in the following error: "Can't release project due to non released dependencies"
I thought that using the aggregator would allow me to do a "synchronised" release of moduleA and moduleB, automatically updating moduleA to depend on moduleB(1.1). What would be the correct way of achieving this?
Thanks
How to release a multi-module project with non released dependencies
To strictly answer this question, this is not possible, at least not with the Maven Release Plugin. And if you don't use the Maven Release Plugin and do the release manually, you should not do that anyway.
Reason: the build of a released should be repeatable, building it later from its sources should give the exact same reasult. Having some SNAPSHOT dependencies in some released POM totally defeats this goal. Which is why the Maven Release Plugin enforces this.
I thought that using the aggregator would allow me to do a "synchronised" release of moduleA and moduleB, automatically updating moduleA to depend on moduleB(1.1). What would be the correct way of achieving this?
Are the versions hard coded? If they are, this might be the problem.
moduleB and moduleA shouldn't declare any version, they inherit it from the parent POM
moduleA should use the built-in properties to declare its dependency on B
<dependency> <groupId>${project.groupId}</groupId> <artifactId>moduleB</artifactId> <version>${project.version}</version> </dependency>
I ran into a similar a problem and the first answer in this thread helped me (see also the example code that is linked)
Th answer is basically add all modules to dependency management of the parent pom and then remove any version information from the "inter-module" dependencies in the modules.
e.g.
parent pom:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>some_group</groupId>
<artifactId>module_A</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>some_group</groupId>
<artifactId>module_B</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
module A:
<dependencies>
<dependency>
<groupId>some_group</groupId>
<artifactId>module_B</artifactId>
</dependency>
</dependencies>
精彩评论