【发布时间】:2010-11-03 23:40:58
【问题描述】:
我有一个多模块项目,比如这个:
main-project/
module1/
module2/
sub-module1/
sub-module2/
sub-module3/
...
module3/
module4/
...
我需要在 Maven2 中定义一组属性(取决于我想要发布我的项目的环境)。
我不会使用<properties>,因为有很多属性...
因此,我使用Properties Maven2 plugin。
属性文件位于main-project/ 目录中。
如何在主 pom.xml 中设置正确的目录,以便指定在哪里可以找到属性文件?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>???/env_${env}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
如果我只设置<file>env_${env}.properties</file>,那么当Maven2编译第一个模块时,会找不到main-project/env_dev.properties文件。如果我设置<file>../env_${env}.properties</file>,则会在父级或任何子模块级引发错误...
【问题讨论】:
-
只要使用
${maven.multiModuleProjectDirectory}
标签: maven-2 properties