Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get spring-boot dependency version in gradle?

I have a standard spring-boot project with org.springframework.boot:spring-boot-gradle-plugin. i know i can override dependency version with e.g.

ext['slf4j.version'] = '1.7.5'

but how can i get the version currently imported by spring-boot plugin so i can use it later in the script? for example:

currentSlf4jVersion = xxx('slf4j.version')
like image 238
piotrek Avatar asked Feb 16 '17 16:02

piotrek


People also ask

How do I check my spring boot version?

In Spring boot application, you can easily obtain the info by altering the Spring Boot Maven/Gradle plugin configuration to generate the build. properties file and then accessing it through BuildProperties object.

How do I know if Gradle dependency has new version?

Go to Android Studio -> Preferences -> Plugins (for Mac) and File -> Settings -> Plugins (for windows) and search “Check for Dependency updates plugin”. Install it and restart android studio. You will be able to see Dependencies tab on the right which will show if any dependency has a new update available.

How do I change the Gradle version in spring boot?

You are going to need to update gradle, as newer spring boot versions are incompatible with older versions of gradle. You can either download the new gradle manually or use gradle wrapper to set the version for your project.


1 Answers

The dependency management plugin that Spring Boot's plugin applies for you provides programmatic access to the properties in imported boms.

You can get the value of the slf4j.version property like this:

dependencyManagement.importedProperties['slf4j.version']
like image 92
Andy Wilkinson Avatar answered Oct 10 '22 20:10

Andy Wilkinson