13
votes

I have a master POM for all projects. The POM contains the following SCM part:

    <groupId>com.company</groupId>
    <artifactId>master</artifactId>
    <version>...</version>
    <packaging>pom</packaging>

    <scm>
        <connection>scm:git:https://[email protected]/scm/${scm.repository.name}/${scm.project.name}.git</connection>
        <developerConnection>scm:git:https://[email protected]/scm/${scm.repository.name}/${scm.project.name}.git</developerConnection>
        <url>https://bitbucket.server.de/scm/${scm.repository.name}/${scm.project.name}.git</url>
        <tag>HEAD</tag>
    </scm>

<properties>
     <project.scm.id>bitbucket-scm</project.scm.id>
     <scm.project.name>maven-master</scm.project.name>
     <scm.repository.name>tsu</scm.repository.name>
</properties>

Now, I have a maven multi module project, this is the parent POM:

    <parent>
        <groupId>com.company</groupId>
        <artifactId>master</artifactId>
        <version>...</version>
    </parent>

    <groupId>com.company.group</groupId>
    <artifactId>project-foo</artifactId>
    <version>...</version>
    <packaging>jar</packaging>

    <name>project FOO</name>

    <properties>
        <scm.project.name>project-foo</scm.project.name>
    </properties>

When executing the release plugin to release the master POM (first snippet), it works fine. However, when executing the release plugin to release the multi module project (second snippet), it fails, saying:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project project-foo: Unable to commit files [ERROR] Provider message: [ERROR] The git-push command failed. [ERROR] Command output: [ERROR] fatal: remote error: Repository not found [ERROR] The requested repository does not exist, or you do not have permission to [ERROR] access it.

In the logs, I can also see the repository URL.

For the working release of the Master POM, it uses

https://user:********@bitbucket.server.de/scm/tsu/maven-master.git refs/heads/dev:refs/heads/dev

For the non-working release of the multi-module project, it uses

https://user:********@bitbucket.server.de/scm/tsu/project-foo.git/project-foo refs/heads/dev:refs/heads/dev

It seems to append the artifact-ID of the project to the URL when releasing the multi-module project.

When copying the entire SCM section to the multi-module project and modifying it, it works. However, I only want to interpolate a single property in the master POM to avoid having to copy the SCM tags to every project.

Any help to fix this issue is appreciated.

1
Possible duplicate of Duplicate artifactId in child pomkevcodez

1 Answers

2
votes

Maven version older or equals to 3.6.1

Since Maven 3.6.1 you can set the following in the pom parent :

<scm child.scm.connection.inherit.append.path="false"  
     child.scm.developerConnection.inherit.append.path="false"  
     child.scm.url.inherit.append.path="false">  
  <connection>scm:git:https://[email protected]/scm/${scm.repository.name}/${scm.project.name}.git</connection>  
  <developerConnection>scm:git:https://[email protected]/scm/${scm.repository.name}/${scm.project.name}.git</developerConnection>  
  <url>https://bitbucket.server.de/scm/${scm.repository.name}/${scm.project.name}.git</url>  
  <tag>HEAD</tag>  
</scm>  

Maven version before 3.6.1

You have to redefine the scm in the children poms :

<scm child.scm.connection.inherit.append.path="false"
     child.scm.developerConnection.inherit.append.path="false"
     child.scm.url.inherit.append.path="false">  
  <connection>scm:git:https://[email protected]/scm/${scm.repository.name}/${scm.project.name}.git</connection>  
  <developerConnection>scm:git:https://[email protected]/scm/${scm.repository.name}/${scm.project.name}.git</developerConnection>  
  <url>https://bitbucket.server.de/scm/${scm.repository.name}/${scm.project.name}.git</url>  
  <tag>HEAD</tag>  
</scm>