Skip to content

Instantly share code, notes, and snippets.

@felix19350
Created February 9, 2021 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felix19350/5c2a9959123a47f32017af84cf638e14 to your computer and use it in GitHub Desktop.
Save felix19350/5c2a9959123a47f32017af84cf638e14 to your computer and use it in GitHub Desktop.
Gradle (groovy) task definitions to be able to run AWS CDK in a project with a main class
/**
* AWS CDK integration. Changes the mainClassName variable and calls run
* */
def cdkMainClassName = "com.rideal.infrastructure.aws.RidealApp"
def originalMainClassName = mainClassName
tasks.register("run-cdk") {
description "Specific run-script for AWS CDK integration"
group "CDK"
doLast {
mainClassName = cdkMainClassName
println("Running up CDK integration")
}
}
tasks.register("reset-main-class"){
description "Resets the main class name after running CDK"
group "CDK"
mainClassName = originalMainClassName
doLast {
println("Cleaning up CDK integration")
}
}
tasks.getByName("run-cdk").configure { finalizedBy tasks.getByName("run") }
tasks.getByName("run").configure {
finalizedBy tasks.getByName("reset-main-class")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment