【发布时间】:2013-08-08 14:30:10
【问题描述】:
我正在尝试将 maven 属性(通过配置文件定义)传递给 antrun 执行:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<!-- ... these are ok -->
</dependencies>
<executions>
<execution>
<configuration>
<target>
<property name="ant_destDir" value="${destDir}" />
<property name="ant_serverDeploy" value="${serverDeploy}" />
<property name="ant_deployDir" value="${deployDir}" />
<property name="ant_userDeploy" value="${userDeploy}" />
<property name="ant_passwordDeploy" value="${passwordDeploy}" />
<!-- correct task definitions for sshexec and scp -->
<sshexec host="${serverDeploy}" username="${userDeploy}"
password="${passwordDeploy}" trust="yes"
command="some command" />
<scp remoteTodir="${userDeploy}@${serverDeploy}:${destDir}"
password="${passwordDeploy}" trust="yes" sftp="true">
<fileset dir="${deployDir}" includes="*.jar" />
</scp>
<sshexec host="${serverDeploy}" username="${userDeploy}"
password="${passwordDeploy}" trust="yes"
command="some command" />
</target>
</configuration>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
属性是在配置文件中定义的,以允许在不同的服务器中进行部署(我知道这不是最好的方法,但这里就是这样做的),如下所示:
<profile>
<id>aprofile</id>
<properties>
<property name="serverDeploy" value="somevalue" />
<property name="userDeploy" value="someuser" />
<property name="passwordDeploy" value="somepassword" />
<!-- and so on -->
</properties>
</profile>
我的问题是我无法在 ant 插件中使用 maven 属性;我试图在 ant 中添加一个<echoproperties> 任务,以查看我拥有哪些属性并且没有任何 maven 属性的痕迹。
是否可以使用 Maven 定义的属性或者我应该使用其他方法?欢迎提出任何建议。
编辑:我根据第一个答案修改了脚本,它仍然不起作用
【问题讨论】: