When creating a custom Gradle plugin, how can I access the extension properties defined in the consuming build.gradleone in the custom plugins setup phase?
See the next MWE.
build.gradle
apply plugin: 'codechecks'
codechecks {
checkstyleConfig = '/home/user/checkstyle.xml'
}
CodechecksPlugin.groovy
class CodechecksPlugin implements Plugin<Project> {
void apply(Project project) {
project.extensions.create('codechecks', CodechecksPluginExtension)
project.apply( [ plugin: 'checkstyle' ] )
project.checkstyle {
configFile = project.codechecks.checkstyleConfig
}
}
}
CodechecksPluginExtension.groovy
class CodechecksPluginExtension {
def checkstyleConfig = 'config/checkstyle/checkstyle.xml'
}
Required Behavior: The plugin checkstyleuses the configuration file defined in the extension build.gradle codechecks.
Actual behavior: The default value of is used CodechecksPluginExtensionbecause the extension build.gradle codecheckshas not yet been evaluated.
I have already tried using all extension extensions codechecksin plugins in closure, but they will not expand correctly due to problems with releasing the class at runtime.
Thank you for your help!