107 lines
3.0 KiB
Groovy
107 lines
3.0 KiB
Groovy
plugins {
|
|
id "com.github.node-gradle.node" version "2.2.4"
|
|
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 {
|
|
@InputDirectory
|
|
File inputDir;
|
|
@OutputDirectory
|
|
File outputDir;
|
|
}
|
|
|
|
task cleanup(type: Delete) {
|
|
delete './src/api', './dist'
|
|
}
|
|
|
|
task ngBuildApp(type: IoNodeTask) {
|
|
script = file('node_modules/@angular/cli/bin/ng')
|
|
args = ['build', '--prod', '--source-map=false']
|
|
inputDir = project.file('./src/')
|
|
outputDir = project.file('./build/outputs/mowesta-app/')
|
|
}
|
|
|
|
task buildApp(type: Copy) {
|
|
from 'build/outputs/mowesta-app'
|
|
into 'dist'
|
|
exclude '**/*.map'
|
|
}
|
|
|
|
task ngBuildForecast(type: IoNodeTask) {
|
|
script = file('node_modules/@angular/cli/bin/ng')
|
|
args = ['build', '--prod', '--source-map=false', 'mowesta-forecast']
|
|
inputDir = project.file('./src/')
|
|
outputDir = project.file('./build/outputs/mowesta-forecast/')
|
|
}
|
|
|
|
task buildForecast(type: IoNodeTask) {
|
|
script = file('./ng-element-concat.js')
|
|
args = ['mowesta-forecast']
|
|
inputDir = project.file('./build/outputs/mowesta-forecast/')
|
|
outputDir = project.file('./dist/')
|
|
}
|
|
|
|
task ngBuildSearch(type: IoNodeTask) {
|
|
script = file('node_modules/@angular/cli/bin/ng')
|
|
args = ['build', '--prod', '--source-map=false', 'mowesta-search']
|
|
inputDir = project.file('./src/')
|
|
outputDir = project.file('./build/outputs/mowesta-search/')
|
|
}
|
|
|
|
task buildSearch(type: IoNodeTask) {
|
|
script = file('./ng-element-concat.js')
|
|
args = ['mowesta-search']
|
|
inputDir = project.file('./build/outputs/mowesta-search/')
|
|
outputDir = project.file('./dist/')
|
|
}
|
|
|
|
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
|
|
ngBuildApp.dependsOn(npmInstall)
|
|
// generate the api before running ng build
|
|
ngBuildApp.dependsOn("generateSwaggerCode")
|
|
buildApp.dependsOn("ngBuildApp")
|
|
|
|
// build Angular Element "mowesta-forecast"
|
|
ngBuildForecast.dependsOn("ngBuildApp")
|
|
buildForecast.dependsOn("ngBuildForecast")
|
|
// build Angular Element "mowesta-search"
|
|
ngBuildSearch.dependsOn("ngBuildApp")
|
|
buildSearch.dependsOn("ngBuildSearch")
|
|
|
|
// run ng build whenever the project is built unless skipAngular is set
|
|
// use e.g. "gradlew site-ear:build -x test -PskipAngular"
|
|
if (! project.hasProperty('skipAngular')) {
|
|
build.dependsOn("buildApp", "buildSearch", "buildForecast")
|
|
}
|
|
|
|
// clean the api folder upon clean
|
|
clean.dependsOn("cleanup")
|