对于战争之路,你可以使用在马文建的地产:
${project.build.directory}/${project.build.finalName}.${project.packaging}
您想要将部署路径设置为自定义 Maven 属性。 有几种方法可以做到这一点。 一个人将它直接设置在 pom 中, 比如 :
<properties>
<deploy.path>C:/Softwares/apache-tomcat-6.0.33/webapps/Test.war</deploy.path>
</properties>
然而,这仍然很难编码 路径在波姆, 只是在一个变量中。
另一种方式是使用 < a href=> http:// mojo.codehaus.org/ properties- maven- plugin/ plugin- info.html" rel=“ nofollow” > properities-maven-plutin 在属性文件中读取。 这样可以将用户特定的设置保存在 pom 之外, 您可以将您的属性文件保存在源控制之外。 但是, 这不是马文最喜欢的做法, 并且该插件在未来版本中可能不再支持 。
Maven 这样做的方法是将您的部署路径存储在 ~/.m2/ sembts. xml 文件中。 此属性会进入一个配置文件, 默认情况下可以激活。 解释请参见 < a href=" http:// maven. apache. org/ examples/ inpinting- properities-via- sebts. html" rel=“ nofollow” > this page a> 。
一旦您安装了. path 变量集, 请更改您的复制语句, 使其看起来像这样 :
<copy file="${project.build.directory}/${project.build.finalName}.${project.packaging}"
tofile="${deploy.path}" />
编辑 :
在最起码的例子项目上,为我设定了以下属性:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<echo message="project.build.directory: ${project.build.directory}"/>
<echo message="project.build.finalName: ${project.build.finalName}"/>
<echo message="project.packaging: ${project.packaging}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
如果那些地产没有为您设置好, 你能张贴你的pom.xml吗?