shellmavenmaven-exec-plugin

Maven: Cannot execute shell script


here is how i am trying to execute a shell script

          <plugin>
                <artifactId>exec-maven-plugin</artifactId>
                <groupId>org.codehaus.mojo</groupId>
                <executions>
                    <execution><!-- Build Python Executable -->
                        <id>Build Python</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${basedir}/scripts/buildPython.sh</executable>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <executable>chmod</executable>
                    <arguments>
                        <argument>+x</argument>
                        <argument>${basedir}/scripts/buildPython.sh</argument>
                    </arguments>
                </configuration>
            </plugin>

but i get

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (Build Python) on project packaging: Command execution failed. Cannot run program "/ajbfiausbf/scripts/buildPython.sh" (in directory "/ajbfiausbf`"): error=13, Permission denied -> [Help 1]

what am i doing wrong?


Solution

  • From your errors, I can see

    error=13, Permission denied

    Try giving permission to the buildPython.sh using ant plugin chmod task to see if it solves the problem. See below,

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>build</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo>run chmod in ${basedir}</echo>
                                <chmod file="${basedir}/scripts/buildPython.sh" perm="ugo+rx"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    

    Permanently, give permission using .gitattributes for git or svn:executable property for subversion.

    Thanks