我想对特定的 Maven 配置文件使用不同的源目录,但是,当我尝试在配置文件定义中指定它时,出现此错误:
Unrecognised tag: 'sourceDirectory' (position: START_TAG seen ...<build>\r\n\t\t\t\t<sourceDirectory>... )
pom中的定义如下:
<profile>
<id>development</id>
<build>
<sourceDirectory>${project.build.directory}/new-src</sourceDirectory>
.
.
.
</build>
</profile>
我想做的是当且仅当此配置文件处于活动状态时在编译之前处理源文件。我的进程将动态更改源文件,将更改后的源文件放入“new-src”目录中,并像通常的“src/main/java”一样编译该目录。生命周期中的其他一切都应该正常运行。如果这种方法有缺陷,有人能指出我正确的方向吗?
根据文档 http://maven.apache.org/guides/introduction/introduction-to-profiles.html#Profiles_in_POMs,你只能改变几个<build>
配置文件中的参数和<sourceDirectory>
不是其中之一。
我会配置主要<build>
从某些属性定义的路径获取源(例如src.dir
),将此属性设置为src/main/java
并在自定义配置文件中覆盖它:
<project>
...
<properties>
<src.dir>src/main/java</src.dir>
</properties>
<build>
<sourceDirectory>${src.dir}</sourceDirectory>
...
</build>
<profiles>
<profile>
<id>development</id>
<properties>
<src.dir>${project.build.directory}/new-src</src.dir>
</properties>
</profile>
</profiles>
</project>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)