Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a script after maven install

I have a Maven project and after I install the project I need to run a script. I want to automize this process. My guess is that by adding something in the pom file I could automize this, but so far i haven't found how to run a script after installation. I only found how to run a script before the maven project has finised installing.

So, how can I run a script after a Maven project as finished installing?

like image 895
Dorin Avatar asked Aug 22 '16 20:08

Dorin


People also ask

How do I run a Maven project after building success?

This time the Console should show the “BUILD SUCCESS” message. To run the maven project, select it and go to “Run As > Java Application”. In the next window, select the main class to execute. In this case, select the App class and click on the Ok button.


1 Answers

Use the http://www.mojohaus.org/exec-maven-plugin/ exec-maven-plugin, in conjunction with an "executions" configuration block that specifies the installation phase. Make sure it is after your maven-install-plugin as plugins are ran in order (within the same phase)

(in build/plugins)  
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5.2</version>
  </plugin>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.5.0</version>
    <executions>
      <execution>
        <phase>install</phase>
        <goals>
           <goal>exec</goal>
        </goals>
        <configuration>
          <executable>do-something.sh</executable>
          <workingDirectory>/some/dir</workingDirectory>
          <arguments>
             <argument>--debug</argument>
             <argument>with_great_effect</argument>
          </arguments>
        </configuration>
      </execution>
    </executions>
  </plugin>
like image 85
Edwin Buck Avatar answered Sep 30 '22 07:09

Edwin Buck