buildscript { dependencies { classpath brazilGradle.tool('BrazilGradleQualityDefaults') } } plugins { id 'brazil-quality-defaults' id "java" id "jacoco" id 'com.github.johnrengelman.shadow' } def resource_name_with_dashes = 'aws-licensemanager-grant' def schema_file = "${resource_name_with_dashes}.json" description 'CloudFormation Resource Provider - ' // Include RPDK generated source by `cfn generate` sourceSets.main.java.srcDirs += ['target/generated-sources/rpdk'] // Inlcude schema into jar sourceSets.main.resources { srcDir 'target/schema' include schema_file } dependencies { compile brazilGradle.build() testCompile brazilGradle.testbuild() } test { useJUnitPlatform() } def cfn_command = "${brazilGradle.path('[AWSCloudFormationRPDKJavaPluginTool]run.runtimefarm')}/bin/cfn" // Generate RPDK wrapper source before compile task rpdkGenerateSource(type: Exec) { workingDir '.' executable = cfn_command args = ['generate'] } task copySchema(type: Copy) { from(".") { include schema_file } into "target/schema" } compileJava.dependsOn(copySchema, rpdkGenerateSource) // Build a shadow jar for resource provider shadowJar { // cfn requires the artifact under target and suffixed with SNAPSHOT.jar classifier = null baseName = "${resource_name_with_dashes}" destinationDir = file('./target') } // Run the tests by default release.dependsOn(check) // Use `cfn` to build a RPDK package include resource provider shadow jar, schema etc. task cfnPackage(type: Exec) { dependsOn shadowJar workingDir '.' executable = cfn_command args = ['submit', '--dry-run'] } // Inject internal files into package for further canary and FAS configuration task rpdkPackage(type: Zip) { dependsOn cfnPackage from zipTree("${resource_name_with_dashes}.zip") // Inject internal files from ("${rootDir}/${resource_name_with_dashes}") { include "settings.internal.json" } from ("${rootDir}/aws-licensemanager-grant") { include "canary-bundle/**/*" } destinationDir = file('./build/rpdk') archiveName("${resource_name_with_dashes}.zip") } assemble.dependsOn(rpdkPackage) // Delete target folder for clean clean.doLast { file('./target').deleteDir() file("${resource_name_with_dashes}.zip").delete() }