How to set up a maven multi-module project with the correct version and version structure

I did not find the best practice for my multi-module maven project in terms of osgi versions, releases and packages,

First of all, this is Versioning and relase. my project has 5-6 auxiliary modules with 200 + jar, so we wanted to use aggregation,

Case 1: do not specify the project version and use the parent version

  • in this case, if I use the maven release plugin and tagging, and pom.next ok for development (ok means jar3 will always use the latest version of jar1, which in itself), but what if I need to fix the patch only for jar1? how can I make relase (it says that the project cannot be released due to the not released dependent parent: 0.0.2-SNAPSHOT) and if I manage to release jar1 0.0.1.1, how can I tell jar3 to use the fixed version of jar1?

    Parent Project (0.0.1 Snapshot)
       Module1
      Jar1
      Jar2
       Module2
       Jar3
        (Dependencies) [Jar1 (project.version), Jar2 (project.version)]
      Jar4
        (Dependencies) [Jar1 (project.version), Jar3 (project.version) ]

2: , jar- pom

  • , release , pom.next i ., jar, hardcoded (jar1.version), , 1- maven ,

    |   
      jar1.version
      jar2.version
      jar3.version
      jar4.version
       Module1
      Jar1 (jar1.version)
      Jar2 (jar2.version)
       Module2 (0.0.1-)
      Jar3 (jar3.version)
         () [Jar1, Jar2]
      Jar4 (0.0.1-)
         () [Jar1, Jar3]

, , , maven

+3
1

() //dependencyManagement \

pom

    <project>
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.seyn</groupId>
 <artifactId>hophop</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <packaging>pom</packaging>
 <name>hophop</name>

 <scm>
  <connection></connection>
  <developerConnection></developerConnection>
  <url></url>
 </scm>

 <properties>
  <hophop1.version>0.0.1-SNAPSHOT</hophop1.version>
  <hophop2.version>0.0.1-SNAPSHOT</hophop2.version>
 </properties>

 <modules>
  <module>../hophop1</module>
  <module>../hophop2</module>
 </modules>

 <build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.1</version>
   </plugin>
  </plugins>
 </build>

 <dependencyManagement>
  <dependencies>
   <dependency>
    <groupId>com.seyn</groupId>
    <artifactId>hophop1</artifactId>
    <version>${hophop1.version}</version>
   </dependency>
  </dependencies>
 </dependencyManagement>
</project>

1 pom:

 <project>
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <artifactId>hophop</artifactId>
  <groupId>com.seyn</groupId>
  <version>0.0.1-SNAPSHOT</version>
  <relativePath>..\hophop</relativePath>
 </parent>
 <groupId>com.seyn</groupId>
 <artifactId>hophop1</artifactId>
 <version>0.0.1-SNAPSHOT</version>

 <scm>
  <connection>seyn</connection>
  <developerConnection>seyn</developerConnection>
  <url>seyn</url>
 </scm>

</project>

2 pom, 1:

    <project>
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <artifactId>hophop</artifactId>
  <groupId>com.seyn</groupId>
  <version>0.0.1-SNAPSHOT</version>
  <relativePath>..\hophop</relativePath>
 </parent>
 <groupId>com.seyn</groupId>
 <artifactId>hophop2</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <scm>
  <connection>seyn</connection>
  <developerConnection>seyn</developerConnection>
  <url>seyn</url>
 </scm>
 <dependencies>
  <dependency>
   <groupId>com.seyn</groupId>
   <artifactId>hophop1</artifactId>
  </dependency>
 </dependencies>
</project>
0

Source: https://habr.com/ru/post/1783211/


All Articles