Maven scm添加到子模块

时间:2016-10-12 07:30:17

标签: java git maven maven-scm-plugin

我有一个java应用程序。它是使用maven构建的,它有父模块和子模块。

当app成功构建时,我需要将提交版本号推送到git。

以下是我的POM:

父pom.xml

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
..
    <modules>
...
        <module>server</module>
...
    </modules>

...
    <scm>
        <url>http://10.72.0.99:8081//service</url>
        <connection>scm:git:10.72.0.99:8081/projectname/service.git</connection>
        <developerConnection>scm:git:git@10.72.0.99:projectname/service.git</developerConnection>
    </scm>

...
</project>

子服务器/ pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>aka</artifactId>

.....

<name>SERVER</name>
    <artifactId>server</artifactId>
    <packaging>war</packaging>
....

<profiles>
...
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.8.1</version>
        <configuration>
            <message>${name.module.server}. ${commitMessage}</message>
            <workingDirectory>/</workingDirectory>
        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                     <goal>checkin</goal>
                 </goals>
            </execution>
        </executions>
   </plugin>
...
</profiles>

Maven日志

[INFO] Executed tasks
[INFO] 
[INFO] --- maven-scm-plugin:1.8.1:checkin (default) @ server ---
[INFO] Executing: /bin/sh -c cd <dir> && git status --porcelain
[INFO] Working directory: <dir> && git commit --verbose -F /tmp/maven-scm-1190574861.commit -a
[INFO] Working directory: <dir>
[INFO] Executing: /bin/sh -c cd <dir> && git symbolic-ref HEAD
[INFO] Working directory: <dir>
[INFO] Executing: /bin/sh -c cd <dir> && git push git@10.72.0.99:project/service.git/server master:master
[INFO] Working directory: <dir>
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] warning: LF will be replaced by CRLF in server/src/main/resources/buildnumber.properties.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in server/src/main/resources/buildnumber.properties.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in server/src/main/resources/buildnumber.properties.
The file will have its original line endings in your working directory.
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

为什么maven-scm-plugin会推送到git push git@10.72.0.99:project/service.git/server master:master

当右侧存储库git@10.72.0.99:project/service.git

如何修复此功能?

1 个答案:

答案 0 :(得分:0)

我自己就碰到了这个。

在每个<scm>文件中加入pom.xml块,以便它们都指向同一个位置。否则,buildnumber-maven-plugin会将模块视为自己的仓库。

相关问题