Плагин Maven Release с мультимодульным проектом, не выдвигающим коммиты на GIT - PullRequest
0 голосов
/ 06 апреля 2020

У меня настроен мультимодульный проект maven.

ROOT_DIR
|
├── maven-hem-commons
├── maven-hem-service
├── maven-release-manager (parent module)

Пом. xml из них

  1. maven-release-manager (родительский модуль)
<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
     <version>1.5.1.RELEASE</version>
 </parent>

 <groupId>com.hemant</groupId>
 <artifactId>maven-release-manager</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <packaging>pom</packaging>
 <name>maven-release-manager</name>
 <description>Demo project for Spring Boot</description>


 <modules>
     <module>../maven-hem-commons</module>
     <module>../maven-hem-service</module>
 </modules>

 <properties>
     <java.version>1.8</java.version>
 </properties>

 <scm>
     <connection>scm:git:https://github.com/hemantvsn/maven-release-manager.git</connection>
     <url>https://github.com/hemantvsn/maven-release-manager</url>
     <developerConnection>scm:git:https://github.com/hemantvsn/maven-release-manager.git</developerConnection>
 </scm>

 <dependencies>
     <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter</artifactId>
     </dependency>

     <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
     </dependency>
 </dependencies>

 <dependencyManagement>
     <dependencies>
         <dependency>
             <groupId>com.hemant</groupId>
             <artifactId>maven-hem-commons</artifactId>
         </dependency>
     </dependencies>
 </dependencyManagement>

 <build>
     <pluginManagement>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </pluginManagement>

     <plugins>
         <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-release-plugin</artifactId>
             <configuration>
                 <preparationGoals>clean verify install</preparationGoals>
                 <commitByProject>true</commitByProject>
                 <autoVersionSubmodules>true</autoVersionSubmodules>
             </configuration>
         </plugin>
     </plugins>
 </build>
</project>

Maven-Hem-Commons
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.hemant</groupId>
        <artifactId>maven-release-manager</artifactId>
        <version>0.0.1</version>
        <relativePath>../maven-release-manager/pom.xml</relativePath>
    </parent>

    <artifactId>maven-hem-commons</artifactId>
    <description>Demo project for Spring Boot</description>
    <packaging>jar</packaging>


    <scm>
        <connection>scm:git:https://github.com/hemantvsn/maven-hem-commons.git</connection>
        <url>https://github.com/hemantvsn/maven-hem-commons</url>
        <developerConnection>scm:git:https://github.com/hemantvsn/maven-hem-commons.git</developerConnection>
  </scm>

</project>
maven-hem-service
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.hemant</groupId>
        <artifactId>maven-release-manager</artifactId>
        <version>0.0.1</version>
        <relativePath>../maven-release-manager/pom.xml</relativePath>
    </parent>

    <artifactId>maven-hem-service</artifactId>
    <description>Demo project for Spring Boot</description>
    <packaging>jar</packaging>

    <scm>
        <connection>scm:git:https://github.com/hemantvsn/maven-hem-service.git</connection>
        <url>https://github.com/hemantvsn/maven-hem-service</url>
        <developerConnection>scm:git:https://github.com/hemantvsn/maven-hem-service.git</developerConnection>
  </scm>

    <dependencies>
        <dependency>
            <groupId>com.hemant</groupId>
            <artifactId>maven-hem-commons</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <!-- We need this as executable jar. Hence spring boot maven plugin -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Все 3 проекта имеют разные GIT репо. Версия по умолчанию для maven-release-plugin: 2.5.3

Когда я пытаюсь запустить подготовку к выпуску для моего родительского проекта,

mvn release:clean release:prepare -Dusername=MY_GIT_USERNAME -Dpassword=MY_GIT_PWD

Сбой при нажатии на родитель. Ниже приведены подробные журналы

------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary:
[INFO] [INFO] 
[INFO] [INFO] maven-release-manager 0.0.1 ........................ SUCCESS [  0.183 s]
[INFO] [INFO] maven-hem-commons .................................. SUCCESS [  0.927 s]
[INFO] [INFO] maven-hem-service 0.0.1 ............................ SUCCESS [  0.432 s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 1.753 s
[INFO] [INFO] Finished at: 2020-04-06T18:47:15+05:30
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-release-manager && git add -- pom.xml
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-release-manager
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-release-manager && git rev-parse --show-toplevel
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-release-manager
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-release-manager && git status --porcelain .
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-release-manager
[WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? release.properties
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-release-manager && git commit --verbose -F /var/folders/pk/071btgcd3nx09yf5lgczk8nc0000gn/T/maven-scm-1359313692.commit pom.xml
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-release-manager
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-release-manager && git symbolic-ref HEAD
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-release-manager
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-release-manager && git push https://username:********@github.com/hemantvsn/maven-release-manager.git refs/heads/master:refs/heads/master
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-release-manager

*****************************************************************
1. It pushed a new commit into my parent as above (verified in github)
2. Now it went to first child's directory in below 
*********************************************************************

[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-hem-commons && git add -- pom.xml
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-hem-commons
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-hem-commons && git rev-parse --show-toplevel
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-hem-commons
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-hem-commons && git status --porcelain .
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-hem-commons
[WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-hem-commons && git commit --verbose -F /var/folders/pk/071btgcd3nx09yf5lgczk8nc0000gn/T/maven-scm-890004212.commit pom.xml
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-hem-commons
[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-hem-commons && git symbolic-ref HEAD
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-hem-commons

********************************************************************
3. I think something fishy is happening here
It cd's into child directory, but is attempting to push to parent's git
********************************************************************

[INFO] Executing: /bin/sh -c cd /Users/hemantvsn/PROJECTS/maven-hem-commons && git push https://username:********@github.com/hemantvsn/maven-release-manager.git refs/heads/master:refs/heads/master
[INFO] Working directory: /Users/hemantvsn/PROJECTS/maven-hem-commons
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] maven-release-manager 0.0.1-SNAPSHOT ............... FAILURE [ 13.488 s]
[INFO] maven-hem-commons .................................. SKIPPED
[INFO] maven-hem-service 0.0.1-SNAPSHOT ................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.739 s
[INFO] Finished at: 2020-04-06T18:47:22+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project maven-release-manager: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To https://github.com/hemantvsn/maven-release-manager.git
[ERROR]  ! [rejected]        master -> master (fetch first)
[ERROR] error: failed to push some refs to 'https://username:password@github.com/hemantvsn/maven-release-manager.git'
[ERROR] hint: Updates were rejected because the remote contains work that you do
[ERROR] hint: not have locally. This is usually caused by another repository pushing
[ERROR] hint: to the same ref. You may want to first integrate the remote changes
[ERROR] hint: (e.g., 'git pull ...') before pushing again.
[ERROR] hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Если вы ссылаетесь на мои комментарии в журналах

1. It pushed a new commit into my parent as above (verified in github)
2. Now it went to first child's directory in below 
3. I think something fishy is happening here
It cd's into child directory, but is attempting to push to parent's git

Я что-то упустил здесь?

...