Reputation: 911
I want to use ant's replace task to replace token in one of the files like this:
version.txt
version.number=${versionNumber}
build.gradle
task writeVersion {
ant.replace {
file 'version.txt'
token 'versionNumber'
value '1.0.0'
}
}
but it is giving me following error :-
A problem occurred evaluating root project '1.01-Exercise-RunYourFirstTask'.
> replace doesn't support the nested "token" element.
Please , help me , how can I use ant's replace task to replace a token in a file or if there is any other function using which I can do it directly from gradle.
Upvotes: 2
Views: 3330
Reputation: 84784
It should be:
task writeVersion << {
ant.replace(
file: 'version.txt',
token: 'versionNumber',
value: '1.0.0'
)
}
and:
version.number=versionNumber
Upvotes: 3