plugins { id "com.moowork.node" version "1.3.1" } description = 'Maptology Web Angular' node { version = '10.16.0' npmVersion = '6.9.0' download = true } class IoNodeTask extends com.moowork.gradle.node.task.NodeTask { @Input File inputFile; @OutputDirectory File outputDir; } task genApi(type: IoNodeTask) { script = file('node_modules/angular4-swagger-client-generator/bin/a4apigen.js') args = ['-s', '../common-api/build/swagger/maptology.json', '-o', './src/api'] inputFile = project.file('../common-api/build/swagger/maptology.json') outputDir = project.file('./src/api/') } task cleanApi(type: Delete) { delete './src/api', './dist' } task ngBuild(type: IoNodeTask) { script = file('node_modules/@angular/cli/bin/ng') args = ['build', '--prod'] inputFile = project.file('./src/') outputDir = project.file('./dist/') } // make sure that common api is built before generating the api genApi.dependsOn(npmInstall) genApi.dependsOn(project(":common-api").tasks['build']) // generate the api before running ng build ngBuild.dependsOn("genApi") // run ng build whenever the project is built build.dependsOn("ngBuild") // clean the api folder upon clean clean.dependsOn("cleanApi")