Ant <sshexec>任务的commandResource中的Maven属性

时间:2015-06-24 14:03:38

标签: java linux maven ant

我正在使用Maven,Ant和sshexec远程运行一些命令。 maven antrun配置如下:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>copyToStg</id>
            <phase>validate</phase>
            <configuration>
                <tasks>
                    <echo message="Backing up my version to path: user@/home/user/app_${maven.build.timestamp}"/>
                    <sshexec host="hostName"
                            trust="yes"
                            username="${username}"
                            password="${password}"
                            commandResource="${project.basedir}/src/main/resources/backupApp.sh"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.9.4</version>
        </dependency>
        <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
            <version>0.1.53</version>
        </dependency>
    </dependencies>
</plugin>

backupApp.sh 文件中我有这样的内容:

#!/usr/bin/env bash
export ANT_HOME=/usr/local/apache-ant-1.7.1
export JAVA_HOME=/usr/java/jdk1.7.0_25
mkdir /xe/users/gold/HTDOCS/ca/backup/ca_${maven.build.timestamp}/ca_lib
cp /users/app/${jar.deployment.path}/${project.build.finalName}.jar /users/app/backup/app_${maven.build.timestamp}/${jar.deployment.path}/${project.build.finalName}.jar
cp /users/app/${projectName}.jnlp /users/app/backup/app_${maven.build.timestamp}/${projectName}.jnlp

我想要的是maven在Ant脚本运行之前用它们的值替换 backupApp.sh 中的所有属性。 我已经尝试过对资源目录进行资源过滤,但它没有替换它们。

0 个答案:

没有答案