6
votes

I would like to use maven-release-plugin in my project. I have a maven repository called Artifactory. I can use mvn release:prepare and mvn release:perform well, but I don't understand why deploy the artifact to libs-snapshot-local and doesn't libs-release-local.

settings.xml:

<server>
    <id>local-artifactory</id>
    <username>user</username>
    <password>password</password>
</server>
...
<mirror>
  <id>local-artifactory</id>
  <mirrorOf>*</mirrorOf>
  <url>http://localhost:8081/artifactory/repo</url>
</mirror>

local-maven-parent:

enter code here<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">
<modelVersion>4.0.0</modelVersion>

<groupId>examples</groupId>
<artifactId>local-maven-parent</artifactId>
<version>1</version>
<packaging>pom</packaging>

<repositories>
    <repository>
        <id>local-artifactory</id>
        <name>Local Central Repository</name>
        <url>http://localhost:8081/artifactory/repo</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

<distributionManagement>
    <repository>
        <id>local-artifactory</id>
        <name>Local Release Repository</name>
        <url>http://localhost:8081/artifactory/libs-release-local</url>
    </repository>
    <snapshotRepository>
        <id>local-artifactory</id>
        <name>Local Snapshot Repository</name>
        <url>http://localhost:8081/artifactory/libs-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>

pom-parent:

<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">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>examples</groupId>
    <artifactId>local-maven-parent</artifactId>
    <version>1</version>
</parent>

<scm>
    <developerConnection>scm:git:git@local-scm:demo.git</developerConnection>
  <tag>HEAD</tag>

<artifactId>pom-parent</artifactId>
<version>1.0.11-SNAPSHOT</version>
<packaging>pom</packaging>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
                <execution>
                    <id>default</id>
                    <goals>
                        <goal>perform</goal>
                    </goals>
                    <configuration>
                        <pomFileName>../${project.artifactId}/pom.xml</pomFileName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

I want the pom-parent-${version} appear in libs-release-local.

2
Have you tried giving the release repository a different id (and unfortunately copying the server settings to that id as well)?Wouter
I did, nothing happend. I think, I have to configure maven-release-plugin configuration section, but I don't know how.Gabor Szabo
Why do you need to configuration maven-release-plugin using a different pomFileName instead of using the defaults? What's the purpose of ? Apart from that what are the error messages you get? Furthermore if you need the pom-parent´ be released you need to release the project where the pom-parent` is located and not the child of it.khmarbaise
I need maven-release-plugin configuration becauase it is a maven modules in a git repository, and the pom.xml isn't in root directory of git. I have a pom.xml called local-maven-parent that contains <distributionManagement>, and I have a pom-parent which have a parent called local-maven-parent. All other maven project child of pom-parent. It is working, but I don't understand why deploy only the snapshots.Gabor Szabo
My answer is wrong. A don't have maven modules, I have maven projects. I need to create maven modules.Gabor Szabo

2 Answers

2
votes

The actual deployment is done via the maven-deploy-plugin, so I would try and configure it there.

Something like:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.1</version>
    <configuration>
         <altReleaseDeploymentRepository>local-artifactory::default::http://localhost:8081/artifactory/libs-release-local</altReleaseDeploymentRepository>
    </configuration>
  </plugin>

Checkout the goal documentation for the plugin for the options: https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html

1
votes

This is a old question, record my answer here if anyone got here.

TL;DR Upgrade the Maven Release Plugin to the latest version.

Refer: This issue is resolved with the combination of Maven 3.2.2 and Maven Release Plugin 2.5

Follow the processes to check: Maven Release Plugin - Prepare a Release

  1. Base on Tag the code in the SCM with a version name: check the tag, it marks on a commit which pom.xml is a RELEASE version without SNAPSHOT

  2. Commit the modified POMs: check the new version which contains SNAPSHOT

If any step is incorrect, the release plugin is not working properly.