Is it possible to run a Bash script from Maven?

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.

Leave a Comment