Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing variables in build.gradle's section plugins

Tags:

gradle

I want to use variables in section Plugins (from gradle.properties)

plugins {
    id 'java'
    id 'war'
    id 'eclipse-wtp'
    id "com.moowork.grunt" version $grunt_version
    id "org.akhikhl.gretty" version $gretty_version
}

but this won't work. Any suggestions?

like image 409
Daniel Ditgens Avatar asked Apr 16 '15 09:04

Daniel Ditgens


1 Answers

By digging deeper in the gradle docs I found this:

The form is:

plugins {
    id «plugin id» version «plugin version»
}

Where «plugin version» and «plugin id» must be constant, literal, strings. No other statements are allowed; their presence will cause a compilation error.

The plugins {} block must also be a top level statement in the buildscript. It cannot be nested inside another construct (e.g. an if-statement or for-loop).

...

If the restrictions of the new syntax are prohibitive, the recommended approach is to apply plugins using the buildscript {} block.

I think I'll give it a try...

like image 79
Daniel Ditgens Avatar answered Sep 28 '22 09:09

Daniel Ditgens