Maven中的财产自动资本化 [英] Property autocapitalization in maven

查看:60
本文介绍了Maven中的财产自动资本化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Maven项目,要求在命令行上设置属性(-Dmy.property = val). 我需要做的是将该字符串转换为全部大写形式,因为该属性是 用于通过maven-resources-plugin替换许多文件中的字符串. 最简单的方法是什么?

I have a maven project that requires a property to be set at the command line(-Dmy.property=val). What I need to do is to convert that string into all caps since that property is used for string replacement in a number of files through the maven-resources-plugin. What's the simplest way to do this?

推荐答案

可以使用groovy插件.下面将其配置为在Maven构建过程的开始运行:

The groovy plugin could be used. The following configures it to run at the beginning of the Maven build process:

        <plugin>
            <groupId>org.codehaus.groovy.maven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <phase>initialize</phase>
                    <goals>
                        <goal>execute</goal>
                  </goals>
                   <configuration>
                      <source>
                      import org.apache.commons.lang.StringUtils

                      project.properties["my.property"] = StringUtils.upperCase(project.properties["my.property"]) 
                     </source>
                 </configuration>
             </execution>
          </executions>
     </plugin>

这篇关于Maven中的财产自动资本化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆