Copying a single file into .jar with a different name using the Gradle task "jar"
How can I copy a single file into .jar with a different name using the Gradle task "jar"?
For example
local:src/main/resources/mypkg_prod.properties → jar-file:/mypkg.properties
You can copy the file into the jar and then do a rename.
This is a link to some information on the rename method from the Gradle docs: https://docs.gradle.org/current/userguide/working_with_files.html#sec:renaming_files
Example:
jar {
from 'my_file.txt'
rename 'my_file.txt', 'my_super_file.txt'
}
Note: If your file is already being included in the jar, just add the rename line to the jar task:
jar {
rename 'mypkg_prod.properties', 'mypkg.properties'
}