I want to try new rule based configuration in Gradle to configure my plugin. Plugin’s purspose is uploading data to cloud storages, like Google Drive or S3. I need a configuration for each storage the user want’s to use. So, what I want to achieve is:
model {
backup { // this is a container for all storages I want to support
googleDrive {
clientId = ''
clientSecret = ''
accessToken = ''
refreshToken = ''
}
s3 {
// S3 specific config (like API keys)
}
}
}
In my plugin I configure rule source for backup element:
class BackupPlugin implements Plugin<Project> {
static class Rules extends RuleSource {
@Model
void backup(BackupPluginExtension backupModel) {}
}
}
@Managed
interface BackupPluginExtension {
GoogleDrive getGoogleDrive()
void setGoogleDrive(GoogleDrive googleDrive)
}
@Managed
interface GoogleDrive {
String getClientId()
void setClientId(String clientId)
String getClientSecret()
void setClientSecret(String clientSecret)
String getAccessToken()
void setAccessToken(String accessToken)
String getRefreshToken()
void setRefreshToken(String refreshToken)
}
But, that doesn’t work saying: Could not find method googleDrive() for arguments [build_8w85xu7hrz3atgeg839d33hzl$_run_closure1_closure2_closure3@1b06ac95] on root project 'test'.
. Looks like it tries to call methods inside backup and not configure nested beans.
So, what is the correct syntax for that?