0

I have a Spring Boot project. My application.properties has a line:

myproject.version=@version@

My build

I have a spring boot project. I need to set project version in application.properties from gradle.

I have tried to use filtering in processResources task and it worked but it affect to other files (corrupt images for example). Then i tried to use filter for only properties file but filter doesn't working inside "filesMatching" statement.

This works ok for replace version in properties but it crushes all images in app:

processResources {
    filesMatching('**/application.properties') {
        expand('version': version)
    }
    filter ReplaceTokens, tokens: [version: version]
}

But this code do nothing:

processResources {
   filesMatching('**/application.properties') {
       expand(project.properties)
       filter ReplaceTokens, tokens: [version: version]
   }
}    

Please, help to understand how i can set property myproject.version in application.properties from gradle.

Max Valeev
  • 75
  • 5
  • I believe the project version belongs to the gradle file itself. If you would move it from properties to gradle file it should be easy to access the value in the script. – arnonuem Jul 10 '19 at 05:54
  • @arnonuem i need to set "myproject.version=" property with project.version form gradle – Max Valeev Jul 10 '19 at 07:11

0 Answers0