我正在尝试构建一个包含xml文件作为资源的jar.我想对该xml应用过滤器以将依赖项的名称插入到xml中.过滤是有效的,因为我能够进入${project.build.finalName}并取代它.我发现了一个暗示,我正在寻找的房产可能是
${project.dependencies[0].artifactId}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.我想替换
<fileName>${project.dependencies[0].artifactId}</fileName>
Run Code Online (Sandbox Code Playgroud)
同
<fileName>OtherLibrary</fileName>
Run Code Online (Sandbox Code Playgroud)
那可能吗?
xml,位于src/main/resources中:
<somenode>
<fileName>${project.dependencies[0].artifactId}</fileName>
</somenode>
Run Code Online (Sandbox Code Playgroud)
pom.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.foo</groupId>
<artifactId>Thing</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Thing</name>
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.pts</groupId>
<artifactId>OtherLibrary</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)