I’m trying to write custom task inside plugin (reusing maven-publish plugin), which will do publishing to S3 bucket.
But I have problem with dynamically adding repositories to current publish repositories.
I’m using down listed code, and I’m getting this error:
‘Cannot configure the ‘publishing’ extension after it has been accessed.’
I found couple post related to subject, but still it’s not to clear for me how to go around this problem?
Does someone have some advice, how to solve this or maybe how to take another approach?
@TaskAction
public void publishToS3() {
setUndefined();
doValidation();
getProject().plugins.withType(MavenPublishPlugin) {
getProject().extensions.configure PublishingExtension, new ClosureBackedAction( {
repositories {
maven {
url "s3://" + awsS3BucketName
credentials(AwsCredentials) {
accessKey awsAccessKey
secretKey awsSecretKey
}
}
}
})
}
}
regards