我正在使用gmaven-plugin将 maven user.name 属性转换为小写。插件配置如下所示
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
import org.apache.commons.lang.StringUtils
project.properties["user.id"] =
StringUtils.lowerCase(project.properties["user.name"])
</source>
</configuration>
</execution>
</executions>
</plugin>
我也有 maven 资源资源插件以过滤模式复制一些资源。manifest.yml 中的条目是:
- name: ${user.id}-app
maven资源插件配置如下
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-context</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<include>manifest.yml</include>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
我的问题是 manifest.yml 文件中没有替换 ${user.id} 。知道我做错了什么吗?
相同的属性也用于其他插件,如 maven-antrun-plugin 和 build-helper-maven-plugin 等。那里的一切都被替换了。如果我直接在 manifest.yml 中使用 ${user.name} 或 POM 文件中的任何其他用户定义属性,事情也可以正常工作。但我正在寻找小写字母。${user.name} 返回大写。
也欢迎任何其他实现相同目标的方法。