Created
February 26, 2018 15:14
-
-
Save mr-archano/6ec5ac4951de036a54c1be0750ae7577 to your computer and use it in GitHub Desktop.
Conditionally apply plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.novoda.build-properties' | |
buildProperties { | |
local { | |
file rootProject.file('local.properties') | |
} | |
} | |
apply from: file('utilities.gradle') | |
maybeApply plugin: 'blah', when: buildProperties.local['applyBlah'].or(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ext.when = { | |
if (it instanceof com.novoda.buildproperties.Entry) { | |
return it.boolean | |
} | |
return it as Boolean | |
} | |
ext.maybeApply = { Map<String, ?> options -> | |
if (when(options.remove('when'))) { | |
logger.log(LogLevel.DEBUG, ">>> '$options.plugin' plugin applied...") | |
apply options | |
} else { | |
logger.log(LogLevel.WARN, ">>> \n/!\\ '$options.plugin' plugin not applied! /!\\\n") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment