Juraj
Juraj

Reputation: 768

maven Return code is: 409, ReasonPhrase: Conflict

I have problem to deploy my multi-module python project with following structure

parent pom.xml # common pom for others project
project/ 
   pom.xml # project pom
   common_features/
        sub-project-1/pom.xml # sub project 1 pom
        sub-project-2/pom.xml # sub project 2 pom

For deployment I use maven

Settings.xml

General maven setting use for build

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- others options -->
  <servers>
    <server>
      <id>artifacts-SNAPSHOTS</id>
      <username>user</username>
      <password>password</password>
    </server>
   </servers>
  <!-- others options -->
</settings>

parent pom.xml

In this case we have the same URL for SNAPSHOT and RELEASE repository

<!-- others options -->
<groupId>com.project.common.group.id</groupId>
<artifactId>project-pom</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>

<!-- others options -->
<distributionManagement>
    <repository>
        <id>artifacts-RELEASES</id>
        <url>${dist.repository.releases}</url>
    </repository>
    <snapshotRepository>
        <id>artifacts-SNAPSHOTS</id>
        <url>${dist.repository.snapshots}</url>
    </snapshotRepository>
</distributionManagement>

<!-- others sections-->
<properties>
    <dist.repository.releases>${artifacts.repository.url}</dist.repository.releases>
    <dist.repository.snapshots>${artifacts.repository.url}</dist.repository.snapshots>
    <artifacts.repository.url>https://domain/artifactory/mvn-repo-dev</artifacts.repository.url>
</properties>

project pom.xml

There you can see that project consists two modules

Parent is general parent. Also I sue maven assembly plugin in order to deploy project into artifactory

<!-- anothers options -->
<parent>
    <groupId>com.project.common.group.id</groupId>
    <artifactId>project-pom</artifactId>
    <version>0.0.1</version>
</parent>

<groupId>com.project.group.id</groupId>
<artifactId>project-pom</artifactId>
<version>1.0.0-SNAPSHOT</version>

<packaging>pom</packaging>

<modules>
    <module>common_features/sub-project-1</module>
    <module>common_features/sub-project-2</module>
</modules>

build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                <descriptors>
                    <descriptor>deploy/artifact-description.xml</descriptor>
                </descriptors>
                <tarLongFileMode>posix</tarLongFileMode>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <phase>package</phase>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jfrog.buildinfo</groupId>
            <artifactId>artifactory-maven-plugin</artifactId>
            <version>2.6.1</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <id>build-info</id>
                    <goals>
                        <goal>publish</goal>
                    </goals>
                    <configuration>
                        <publisher>
                            <contextUrl>https://domain/artifactory</contextUrl>
                            <repoKey>mvn-repo-dev</repoKey>
                            <snapshotRepoKey>mvn-repo-dev</snapshotRepoKey>
                            <publishArtifacts>true</publishArtifacts>
                            <publishBuildInfo>true</publishBuildInfo>
                            <username>deployUser</username>
                            <password>deployPwd</password>
                        </publisher>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

artifact-description.xml

I want to deploy only some section therefore I define the following deployment file. With this I ensure that into package will be deploy only common features and project specific scripts/codes

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-    plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>${distributionId}</id>
    <formats>
        <format>tar.gz</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <outputDirectory>project/${subProjectName}/</outputDirectory>
            <directory>${basedir}/..</directory>
            <fileMode>0755</fileMode>
            <lineEnding>unix</lineEnding>
            <includes>
                <include>/*.*</include>
                <include>/sub-${subProjectName}/*</include>
            </includes>
            <excludes>
                <exclude>**/*.pyc</exclude>
                <exclude>**/*.xls</exclude>
                <exclude>**/*.xlsx</exclude>
                <exclude>**/pom.xml</exclude>
                <exclude>**/target</exclude>
                <exclude>**/deploy</exclude>
                <exclude>**/.venv</exclude>
            </excludes>
        </fileSet>
    </fileSets>
</assembly>

sub-project-1 pom.xml

This is only simple pom without others plugins and build options

<parent>
    <groupId>com.project.group.id</groupId>
    <artifactId>project-pom</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <relativePath>../../pom.xml</relativePath>
</parent>

<packaging>pom</packaging>
<groupId>com.project.group.id</groupId>
<artifactId>sub-project-1</artifactId>
<version>1.0.0-SNAPSHOT</version>

<properties>
    <subProjectName>project-1</subProjectName>
</properties>

sub-project-2 pom.xml

The same pom.xml as for sub-project-1

<parent>
    <groupId>com.project.group.id</groupId>
    <artifactId>project-pom</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <relativePath>../../pom.xml</relativePath>
</parent>

<packaging>pom</packaging>
<groupId>com.project.group.id</groupId>
<artifactId>sub-project-2</artifactId>
<version>1.0.0-SNAPSHOT</version>

<properties>
    <subProjectName>project-2</subProjectName>
</properties>

Now I want to build and upload only sub-project-1 it into artifactory and therefore I will use the following maven command:

mvn -e -B -U -X clean deploy --projects :sub-project-1 -DskipIntegrationTests=false -DskipCoverageReport=false

But then following error occur:

Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://domain/artifactory/mvn-repo-dev/com/project/group/id/project/project-1/1.0.0-SNAPSHOT/sub-project-1-1.0.0-20190723.081454-1.pom. Return code is: 409, ReasonPhrase: Conflict.
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:627)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:541)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:523)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:517)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:497)
    at org.eclipse.aether.transport.wagon.WagonTransporter$PutTaskRunner.run(WagonTransporter.java:644)
    at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
    at org.eclipse.aether.transport.wagon.WagonTransporter.put(WagonTransporter.java:410)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PutTaskRunner.runTask(BasicRepositoryConnector.java:510)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
    ... 32 more

Now I am not sure what is wrong and I spend a lot of hours of investigation this issue but nothing found. Please do you have some suggestions what is wrong here? Thanks a lot

Upvotes: 1

Views: 5079

Answers (1)

Juraj
Juraj

Reputation: 768

I found where is the problem. Within parent pom.xml there was the following plugin which change artifactId. I do not know why I got error 409 but finally this was a reason:

        <plugin>
            <groupId>org.codehaus.groovy.maven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>pre-clean</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                    <configuration>
                        <source>
                            project.getModel().setArtifactId(project.properties["someProperty"].replaceAll('_',
                            '-'))
                            project.getArtifact().setArtifactId(project.properties["someProperty"].replaceAll('_',
                            '-'))
                        </source>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Upvotes: 2

Related Questions