views:

278

answers:

1

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>

+1  A: 

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
Using <goals>install</goals> switch "deploy" to "install" task. Thanks. It should be enough just to do:<goals>install exec:exec</install> but release:perform does not like exec:exec: http://stackoverflow.com/questions/3445396/performrelease-calling-execexec-does-not-work-bug
Sergio Oliveira Jr.
@Sergio Well, that's not what I suggested, I'm not sure this can work.
Pascal Thivent
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 <phase> 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.
Sergio Oliveira Jr.
@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
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.
Sergio Oliveira Jr.
@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