Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run a Bash script from Maven?

Tags:

bash

maven

For creating configuration of my application I need to run bash script. Is it possible to integrate execution of Bash scripts in Maven, maybe there are some plugins?

like image 751
user710818 Avatar asked Dec 08 '11 15:12

user710818


People also ask

What is maven Shell?

Maven Shell is a CLI interface for Maven that enables faster turn-around, and a more intelligent interaction with repositories and projects.


2 Answers

Could the Bash Maven Plugin help you? (Disclaimer: I initiated it, so please send me feedback)

<build>     <plugins>         <plugin>             <!-- Run with:                 mvn bash:run                 mvn install             -->             <groupId>com.atlassian.maven.plugins</groupId>             <artifactId>bash-maven-plugin</artifactId>             <version>1.0-SNAPSHOT</version>             <executions>                 <execution>                     <id>test</id>                     <phase>integration-test</phase>                     <goals>                         <goal>run</goal>                     </goals>                 </execution>             </executions>             <configuration>                 <script>                     # Here you can execute shell commands                     echo "Tomcat will start"                     /opt/apache-tomcat/bin/startup.sh                 </script>             </configuration>         </plugin>     </plugins> </build> 

You will need to install this maven plugin in your own Maven repo.

Like Konstantin: When you execute a shell script, you're not portable anymore.

like image 190
Adrien Avatar answered Sep 30 '22 22:09

Adrien


You can do this, see answer:

I want to execute shell commands from maven's pom.xml

But it is not advisable, as this produces not so portable builds. Why do you need this in first place? Using this plugin usually indicates some weird necessity in project build

like image 34
Konstantin Pribluda Avatar answered Sep 30 '22 22:09

Konstantin Pribluda