Extra Properties Extensions sind für globale Properties; mir würde spontan bspw. einfallen, die eine Versionsnummer für meine drölf Spring-Dependencies so zu zentralisieren.
Aber, Folgendes geht nicht:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
ext.springVersion = '1.5.6.RELEASE' buildscript { dependencies { // doesn't work! classpath("org.springframework.boot:spring-boot-gradle-plugin:${springVersion}") } } dependencies { // works: compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springVersion}" // ... } |
, weil buildscript vor allem anderen ausgewertet wird. Aber so geht’s:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
buildscript { ext.springVersion = '1.5.6.RELEASE' dependencies { // works :-) classpath("org.springframework.boot:spring-boot-gradle-plugin:${springVersion}") } } dependencies { // still works: compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springVersion}" // ... } |
Achtung: Bei mir ging das ausschließlich in geschweiften Klammern und Quotes.