92 lines
2.7 KiB
Groovy
92 lines
2.7 KiB
Groovy
plugins {
|
|
id "com.moowork.node" version "1.3.1"
|
|
id 'org.hidetake.swagger.generator' version '2.18.1'
|
|
}
|
|
|
|
description = 'Mowesta Web Angular'
|
|
|
|
dependencies {
|
|
swaggerCodegen 'io.swagger:swagger-codegen-cli:2.4.12'
|
|
}
|
|
|
|
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 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/')
|
|
}
|
|
|
|
task ngBuildWeatherForecastToday(type: IoNodeTask) {
|
|
script = file('node_modules/@angular/cli/bin/ng')
|
|
args = ['build', '--prod', 'weather-forecast-today']
|
|
inputFile = project.file('./projects/weather-forecast-today/src/')
|
|
outputDir = project.file('./dist/weather-forecast-today/')
|
|
}
|
|
|
|
task generateWeatherForecastToday(type: NodeTask) {
|
|
script = file('./ng-element-concat.js')
|
|
args = ['weather-forecast-today']
|
|
}
|
|
|
|
task ngBuildWeatherSearch(type: IoNodeTask) {
|
|
script = file('node_modules/@angular/cli/bin/ng')
|
|
args = ['build', '--prod', 'weather-search']
|
|
inputFile = project.file('./projects/weather-search/src/')
|
|
outputDir = project.file('./dist/weather-search/')
|
|
}
|
|
|
|
task generateWeatherSearch(type: NodeTask) {
|
|
script = file('./ng-element-concat.js')
|
|
args = ['weather-search']
|
|
}
|
|
|
|
swaggerSources {
|
|
mowesta {
|
|
inputFile = file(project(':common-api:').buildDir.path + '/swagger/mowesta.json')
|
|
code {
|
|
outputDir = file("./src/api/")
|
|
language = 'typescript-angular'
|
|
configFile = file('apiconfig.json')
|
|
components = [models: true, apis: 'Default', supportingFiles: 'configuration.ts,encoder.ts,api.ts,models.ts,variables.ts']
|
|
wipeOutputDir = true
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// require api build to access swagger definition
|
|
tasks['resolveSwaggerTemplate'].dependsOn(project(':common-api').tasks['build'])
|
|
// make sure that common api is built before generating the api
|
|
ngBuild.dependsOn(npmInstall)
|
|
// generate the api before running ng build
|
|
ngBuild.dependsOn("generateSwaggerCode")
|
|
// build Angular Element "weather-forecast-today" after ngBuild finishes
|
|
ngBuildWeatherForecastToday.mustRunAfter("ngBuild")
|
|
generateWeatherForecastToday.dependsOn("ngBuildWeatherForecastToday")
|
|
// build Angular Element "weather-search" after ngBuild finishes
|
|
ngBuildWeatherSearch.mustRunAfter("ngBuild")
|
|
generateWeatherForecastToday.dependsOn("ngBuildWeatherSearch")
|
|
|
|
// run ng build whenever the project is built
|
|
build.dependsOn("ngBuild", "generateWeatherForecastToday", "generateWeatherSearch")
|
|
|
|
// clean the api folder upon clean
|
|
clean.dependsOn("cleanApi")
|