Maven deploy plugin disable redeployment

Viewed 383

Is it possible to disable redeployment just from pom level via deployment plugin configuration?

Im trying to prevent redeployment of few artifacts in artifactory but dont want to set this globaly (i know it should be dole globaly, but im just a user of that artifactory and it is not up to me to decide). Thats why i was wondering if it is posible to configure my artifacts poms to fail if deployment would in fact mean redeployment of non SNAPSHOT version.

Maven used: 3.6.1

1 Answers

There is no parameter for deploy:deploy to achieve this. There are two workarounds to prevent unintentional deploying at least:

1. deploy:deploy <skip>

    <properties>
        <skipDeploy>true</skipDeploy>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.0.0-M1</version>
                <configuration>
                    <skip>${skipDeploy}</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

Deploy with:

mvn deploy -DskipDeploy=false

2. Deploy to local TEMP by default, use profile to really deploy

    <distributionManagement>
        <repository>
            <uniqueVersion>false</uniqueVersion>
            <id>local-dummy-repo</id>
            <name>local dummy repository to prevent unintentional re-deploying</name>
            <url>file://${env.TEMP}/maven-dummy-repo</url>
            <layout>default</layout>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>deploy</id>
            <distributionManagement>
                <repository>
                    <uniqueVersion>false</uniqueVersion>
                    <id>repo</id>
                    <name>real repository</name>
                    <url>scheme://authority/path</url>
                    <layout>default</layout>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

Deploy with:

mvn deploy -Pdeploy
Related