In a Maven project, how can I automatically update the version all child modules, plus the parent?

前端 未结 4 670
梦谈多话
梦谈多话 2021-01-30 02:05

I have a multi-module project.

parent POM (1.0-SNAPSHOT)
|-- module1 (1.0-SNAPSHOT)
|-- module2 (1.0-SNAPSHOT)
`-- module3 (1.0-SNAPSHOT)

When I execute m

4条回答
  •  误落风尘
    2021-01-30 02:33

    1. Make the version of all sub-project be defined in its parent pom.xml.
    2. Make sure all sub-projects versions are the same to their parent's version.

      com.xyz
      module-1
      jar
      
      
        com.xyz
        xyz-parent
        1.0.123-SNAPSHOT
      
      

       

      
      
      
        4.0.0
        xyz-parent
        com.xyz
        1.0.123-SNAPSHOT
        pom
        xyz-parent
      
        
          
      
          
          
            com.xyz
            module-1
            ${project.version}
          
      
          
            com.xyz
            module-2
            ${project.version}
          
      
        
      
      
    3. Create another pom.xml to group those project together.

         
        ../xyz-parent
        ../module-1
        ../module-2      
      
      
    4. Then update the parent project's version and then build it by below command.

      mvn versions:set -DnewVersion=1.0.1004-SNAPSHOT
      mvn clean install
      
    5. Then update the parent's version which is defined in those sub-project to the latset one

      mvn -N versions:update-child-modules
      
    6. Then build them together.

      @echo on
      cd   .\xyz-parent
      call mvn versions:set -DnewVersion=1.0.1004-SNAPSHOT -o
      call mvn versions:commit -o
      call mvn clean install -o
      :::http://www.mojohaus.org/versions-maven-plugin/examples/update-child-modules.html
      cd ..\xyz-buildaggregate-ide
      call mvn -N versions:update-child-modules -o
      call mvn clean install -o
      

提交回复
热议问题