Replace token in file before building, but keep token in sources

后端 未结 5 1247
孤街浪徒
孤街浪徒 2021-02-12 03:33

I want to replace a @VERSION@ token in a java source file with a version before building (Gradle is my build system of choice).

In my current script a

5条回答
  •  清歌不尽
    2021-02-12 04:04

    To complement other answers, I found this idiom more simple if there's only one value you are looking to change:

    task generateSources(type: Copy) {
        from 'src/main/java'
        into 'build/src/main/java'
        filter { line -> line.replaceAll('xxx', 'aaa') }
    }
    

提交回复
热议问题