【发布时间】:2012-04-23 13:46:20
【问题描述】:
我正在尝试在 Maven 在 META-INF/maven/${groupId}/${artifactId} 位置生成的 pom.properties 文件中添加自定义值
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<build>${BUILD_TAG}</build>
</manifestEntries>
<addMavenDescriptor>true</addMavenDescriptor>
<pomPropertiesFile>${project.build.directory}\interface.properties</pomPropertiesFile>
</archive>
</configuration>
</plugin>
interface.properties文件的内容是
# Build Properties
buildId=746
使用documentation我已经将pomPropertiesFile元素指向一个外部属性,但是运行mvn install后生成的pom.properties文件仍然有默认内容
pomPropertiesFile 元素的正确用法是什么?
编辑
我认为问题出在 org.apache.maven.archiver.PomPropertiesUtil 上。如果您查看source 中的方法sameContents,如果外部文件中的属性与默认值相同,则返回true,如果不同,则返回false。如果sameContents 的结果为假,则忽略外部文件的内容。
果然,这已经是logged的bug了
【问题讨论】:
-
interface.properties长什么样子? -
这是一个标准的属性文件。
-
不要在 Maven pom 中使用“\”。请改用“/”。
-
不要将答案添加到问题本身。在 StackOverflow 上被认为是不好的做法。相反,请在页面末尾按
Answer Your Question并将您的答案放在那里。