Col*_*ert 83
您应该使用配置文件.
<profiles>
<profile>
<id>otherOutputDir</id>
<build>
<directory>yourDirectory</directory>
</build>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
并开始使用您的个人资料
mvn compile -PotherOutputDir
Run Code Online (Sandbox Code Playgroud)
如果你真的想从命令行定义你的目录,你可以做这样的事情(根本不推荐):
<properties>
<buildDirectory>${project.basedir}/target</buildDirectory>
</properties>
<build>
<directory>${buildDirectory}</directory>
</build>
Run Code Online (Sandbox Code Playgroud)
并编译如下:
mvn compile -DbuildDirectory=test
Run Code Online (Sandbox Code Playgroud)
那是因为您无法使用更改目标目录 -Dproject.build.directory
Kri*_*ket 27
科林是正确的,应该使用配置文件.但是,他的回答硬编码了配置文件中的目标目录.另一种解决方案是添加如下配置文件:
<profile>
<id>alternateBuildDir</id>
<activation>
<property>
<name>alt.build.dir</name>
</property>
</activation>
<build>
<directory>${alt.build.dir}</directory>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
这样做会产生将构建目录更改为alt.build.dir属性给出的任何内容的效果,该属性可以在POM中,在用户的设置中或在命令行中给出.如果该属性不存在,则编译将在正常目标目录中进行.
归档时间: |
|
查看次数: |
101982 次 |
最近记录: |