鉴于,
Apache Maven 3.0.3和带有
的src / main / resources / application.properties文件 project.root=${basedir}
和带有
的pom.xml文件<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
...
当我运行“mvn clean package”时,我得到一个带有过滤的target / classes / application.properties文件
project.root=/path/to/MyProject
但是,jar 中包含的application.properties文件尚未过滤。
project.root=${basedir}
为什么jar中包含的application.properties文件未被过滤?根据{{3}},来自目标/类的过滤属性文件应该包含在jar中。
答案 0 :(得分:1)
自助服务。
需要添加<Include-Resources>{maven-resources}</Include-Resources>
配置maven-bundle-plugin。
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<Include-Resources>{maven-resources}</Include-Resources>
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>${bundle.namespace}.*;version="${project.version}"</Export-Package>
<Import-Package>
答案 1 :(得分:1)
感谢您发表这篇文章,鲍勃。我的解决方案看起来有点不同,可能是因为我使用的是插件的更高版本:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<!--
The plugin must be instructed to retrieve the filtered files from the "target/classes" directory.
Otherwise, it will copy the unfiltered versions in "src/main/resources" to the JAR.
-->
<Include-Resource>{maven-resources}, {filtered-file.properties=target/classes/filtered-file.properties}</Include-Resource>
</instructions>
</configuration>
</plugin>