I have a simple Gradle build script to compile and package (like an application plugin) my Java application. The only thing I do not do is replace the current version number in a simple .properties file.
I created the file 'src / main / resources / app-info.properties' with one line 'application.version = @version @'. No. I want to replace this version line whenever a file is copied to the build folder (think this happens during build).
I have already tried a simple solution with ReplaceTokens ants. This replaced the version, but also broke my .png files in resources.
So, is there a simple solution to just replace the tokens in one file during the build task (or does any task process the copy in the build folder)?
Thanks for any help! Ben
====== Edit based on a comment from Opal =====
Based on the hint, I added the following:
import org.apache.tools.ant.filters.ReplaceTokens // ... build { from('src/main/resources') { include '*.properties' filter(ReplaceTokens, tokens: [version : project.version]) } }
What causes this error:
Could not find method from () for arguments [src / main / resources, build_vbjud9ah7v3pj5e7c5bkm490b $ _run_closure6_closure12 @ 43ead1a8] in the root project
Does it seem like I'm in the wrong task?
====== Editing the completeness of adding an Opals-based solution offers =====
Thanks to the man, the following working solution!
processResources { from('src/main/resources') { include '*.properties' filter(ReplaceTokens, tokens: [version : project.version]) } }
source share