29

I am using the maven release plugin. Problem is simple: I don't want to do a deploy on release:perform. I actually want to execute a shell script that will do the deploy for me. So I have two things to accomplish:

  1. Somehow disable the default "deploy" goal from release:perform

  2. Somehow make release:perform call the exec:exec plugin to execute a shell script

Here is my pom:

<plugin>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <tagBase>svn://saoj-la.dyndns.org/webapp-test/tags</tagBase>
        <connectionUrl>scm:svn:svn://saoj-la.dyndns.org/webapp-test/trunk</connectionUrl>
    </configuration>
</plugin>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>/bin/sh</executable>
        <arguments>
            <argument>run.sh</argument>
        </arguments>
    </configuration>
</plugin>
Gray
  • 115,027
  • 24
  • 293
  • 354
TraderJoeChicago
  • 6,205
  • 8
  • 50
  • 54

2 Answers2

56

A little late, but for reference:

For your step 1, you can disable the maven deploy step by using the "skip" option. Click here for reference.

On the commandline you could call something like:

mvn release:perform -Darguments="-Dmaven.deploy.skip=true"
Marja
  • 668
  • 1
  • 5
  • 6
  • 2
    My use case: migrating SVN repos to Git and wanted to validate SCM urls in my pom.xml. Running `mvn release:prepare; mvn release:perform -Darguments="-Dmaven.deploy.skip=true"` allowed me to release fake versions in my fork and not push fake artifacts to artifactory – joao cenoura Jul 19 '16 at 10:29
11

I am using the maven release plugin. Problem is simple: I don't want to do a deploy on release:perform. I actually want to execute a shell script that will do the deploy for me.

I must be missing something because when I read this, I don't see the point of the script... But let's just say I don't get it.

Somehow disable the default "deploy" goal from release:perform

According to the documentation of release:perform, you can use the optional goals parameter to specify:

A space separated list of goals to execute on deployment. Default value is either deploy or deploy site-deploy, if the project has a <distributionManagement>/<site> element.

You could maybe use install instead of deploy.

Somehow make release:perform call the exec:exec plugin to execute a shell script

Bind it on install in a profile activated during release. Here is one way to do this:

<profile>
  <!-- Profile used when the release plugin executes. -->
  <id>release</id>
  <activation>
    <property>
      <!-- This property is automatically defined by the Maven release plugin when executing
           a release. Thus this profile will be automatically enabled when releasing -->
      <name>performRelease</name>
      <value>true</value>
    </property>
  </activation>
  <build>
    ...
  </build>
</profile>

But honestly, there is something weird with your request. Maybe giving more details would help.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • 1
    Using install switch "deploy" to "install" task. Thanks. It should be enough just to do: install exec:exec but release:perform does not like exec:exec: http://stackoverflow.com/questions/3445396/performrelease-calling-execexec-does-not-work-bug – TraderJoeChicago Aug 10 '10 at 01:29
  • 1
    @Sergio Well, that's not what I suggested, I'm not sure this can work. – Pascal Thivent Aug 10 '10 at 10:11
  • Hey Pascal. What you suggest does not work either. Because release:perform forks another process, somehow the profile is not activated. Another problem is the tag, because release:perform is a goal, not a phase. Anyways: my solution is to force the user to call exec:exec manually after release:perform. There is no easy way to cascade an exec:exec after release:perform. What I don't like about Maven is this. Simple things become extremely difficult. With ant you can accomplish anything you want. Not saying that ANT is better, just that it respects the KISS principle. – TraderJoeChicago Aug 10 '10 at 14:39
  • 1
    @Sergio Weird, the profile stuff does work for me. Second, I explicitly wrote to try to bind on the `install` phase, not `release:perform`. Third, I don't want to discuss that KISS thing (this is maybe debatable but your use case doesn't look KISS) but if Maven doesn't work like YOU want, my advice is don't use it. – Pascal Thivent Aug 10 '10 at 14:58
  • I am on MAC. Could that be a mac related bug? Anyways: I would love to see a simple pom.xml that cascades an exec:exec after a release:perform. I understood the phase install, but that does not work either. And about my case: All I want is: perform a release from tagged SVN with release:perform and run a shell script to deploy with a different profile for QA and PRODUCTION so a different deploy script is executed for each environment. – TraderJoeChicago Aug 10 '10 at 15:11
  • 1
    @Sergio Being on MAC shouldn't be an issue, at least in theory. And I can't easily test your scenario so I'm afraid I won't be able to help further (I still think binding `exec:exec` on some phase inside a profile is the way to go though). – Pascal Thivent Aug 11 '10 at 13:17
  • @PascalThivent: We have a hard requirement that developers manage version control, including triggering of releases by pushing into a branch, and TeamCity manages deployment to Nexus, without having write access to the VCS. This is an example that could require muting the deploy stage in the release plugin. – Mihai Danila Mar 11 '13 at 23:00
  • @PascalThivent: That said, is there something more innocuous than `install` that can be subsituted? I would much prefer not running any goals... – Mihai Danila Mar 11 '13 at 23:01