简体   繁体   中英

Maven Release build on a project - artifact version number

I have a maven project with the following structure

Project
- pom.xml
--- Module1
--- pom.xml for Module1
--- Module2
--- pom.xml for Module2
--- Module3
--- pom.xml for Module3
------- Module31
------- pom.xml for Module31
------- Module32
------- pom.xml for Module32

ie Project has it's pom.xml (packages as pom) and has modules. Each of the modules have a <parent> .. </parent> section in the individual ModuleX pom.xml file where it can be either set to artifact of "Project" (which is defined in root pom.xml) -- OR it can be set to any other project2/project3/projectN artifact.

Now, due to this, I see if Project1 root pom.xml is set to 0.0.1-SNAPSHOT and if I want to create a release candidate (non-snapshot) build "0.0.1", then I expect all the modules should generate artifact with the same version which is set in Project's root pom.xml.

I noticed, that Module2 pom.xml has a parent which is some other project (for ex: Project2) and version id of this parent is set to "0.0.7-SNAPSHOT" and Module2 pom.xml (under Project) also has some of the dependencies using Project2's artifacts.

The same case exists for Module3 and Module32 where <parent> section has a different parent (set to ProjectN where N can be any number) and has dependencies on those or any ProjectN project's artifacts.

My question :

1. If I creating a 0.0.1 (non-snapshot) build of Project, then what version id artifacts Maven will generate for the root pom, for Module1, Module2, Module3 and Module31/32?

2. How can I make sure, 0.0.1 release of Project -- generates same version# 0.0.1 for all of its modules (even though the <parent> section of those modules uses a different project**N** and have different / newer <version>..</version> value set in the <parent> section).

Thanks.

Have a look at the maven-release-plugin , it does exactly want you want. release:prepare is about verifying and updating poms, tagging the project and preparing it for the next development cycle. release:perform is about building the projects based on the tag and pushing the artifacts to a remote repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM