以不同名称将文件包含在 war 中的简洁方法

Concise way to include a file in a war with a different name

现在,为了在 war 中包含开发人员相关文件,我将其复制到临时目录中,重命名,然后将其包含在 war 中:

war {
    copy {
        from "run_"+System.getProperty('user.name')+".properties"
        into "build/tmp"
        rename ("run_"+System.getProperty('user.name')+".properties", "run.properties")
    }
    webInf {
        from('build/tmp') {
            include "run.properties"
        }
    }
}

它有效,但非常冗长。我可以为文件名定义一个变量,但这并不会更简洁。

我确定有一个简洁的语法可以做到这一点,可能不需要创建任何临时文件。

这是什么?

你可以做到

war {
    webInf {
       from("run_${System.getProperty('user.name')}.properties") {
          rename {
             'run.properties'
          }
       }
    }
}