9

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')
piotrek
  • 13,982
  • 13
  • 79
  • 165

2 Answers2

12

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']
Michel Jung
  • 2,966
  • 6
  • 31
  • 51
Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
1

You can find your gradle project dependencies using command

gradle dependencies

For All:

gradle listAllDependencies

For sub-project:

gradle :<subproject>:dependencies

This will output dependencies

fabfas
  • 2,200
  • 1
  • 21
  • 21
  • sorry if i wasn't clear - i need to get it inside the script, so i can use later – piotrek Feb 16 '17 at 17:10
  • Once you list your dependencies, you'll see the transitive dependencies and its detail imported by spring-boot. – fabfas Feb 16 '17 at 17:15
  • @piotrek you define your dependencies in gradle. You can force gradle to include/exclude when resolving dependencies but within your script or code you just use that API. Having all said, you can still determine the API version inside your code programatically but I will not recommend this approach. – fabfas Feb 17 '17 at 06:52