我在 pom.xml
中设置了配置文件,如下所示:
<profile>
<id><em>profileId1</em></id>
<build>
<filters>
<filter>src/main/filters/<em>profileId1</em>.properties</filter>
</filters>
// rest of the profile
</profile>
<profile>
<id><em>profileId2</em></id>
<build>
<filters>
<filter>src/main/filters/<em>profileId2</em>.properties</filter>
</filters>
// rest of the profile
</profile>
问题:
有没有什么方法可以从所有配置文件中提取这一段,这样就不需要为每个配置文件重复它(并且可能拼写错误)?
最佳答案
使用 maven 2.2.1 及更高版本,我能够使用以下方法获取第一个 Activity 配置文件的 ID:
${project.activeProfiles[0].id}
如果没有至少一个 Activity 配置文件,这当然会失败。
使用
${project.profiles[0].id}
正如 Pascal 所建议的那样,不对我有用。
提示:在调查这个问题时,我真的开始喜欢 mvn help:evaluate
。
关于java - Maven - 我可以在配置文件定义中引用配置文件 ID 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2012198/