如何通过maven执行shell脚本

在maven的pom.xml文件中添加:

<build>
        <finalName>demofinalName>
        <plugins>
            <plugin>
                <artifactId>exec-maven-pluginartifactId>
                <groupId>org.codehaus.mojogroupId>
                <executions>
                    <execution>
                        <id>uncompressid>
                        <phase>installphase>
                        <goals>
                            <goal>execgoal>
                        goals>
                    execution>
                executions>
                <configuration>
                    <executable>${basedir}/../check-style/test.shexecutable>
                configuration>
            plugin>
        plugins>
    build>

我的test.sh脚本:

#!/bin/bash
## 获取当前目录路径
check_style_path=$(cd `dirname $0`; pwd)
## 获取上级目录路径
project_path=$(dirname "$PWD")
echo $project_path
echo $check_style_path
cp $check_style_path/pre-commit $project_path/.git/hooks/

你可能感兴趣的:(Linux命令笔记)