blob: 058bda9b0d719bb0415f04aca3592146daa7302c [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
plugins {
id "com.github.node-gradle.node" version "2.2.3"
}
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
description = 'MDM Web Client'
def distDir = "${project.buildDir}/dist"
def webappDir = "src/main/webapp"
System.setProperty('file.encoding', 'UTF-8')
dependencies {
implementation project(':doc:GettingStartedGuide')
implementation project(':doc:UserGuide')
}
/* TODO mko, 14.05.2020: configure linting
task map_tslint(type: Copy) {
File tsLintFile = file("${project.buildDir}/node/coverage/tslint_out.json")
File mappedTsLintFile = file("${project.buildDir}/node/coverage/tslint_out_mapped.json")
if (tsLintFile.exists()) {
String contents = tsLintFile.getText('UTF-8')
contents = contents.replaceAll( 'src/app', 'src/main/webapp/src/app' )
mappedTsLintFile.write(contents, 'UTF-8')
}
}
*/
sonarqube {
properties {
property "sonar.sources", "${webappDir}/src,src/main/java"
property "sonar.exclusions", "${webappDir}/node_modules/**, ${webappDir}/coverage/**, ${distDir}/**,**/*.spec.ts, **/*.js"
property "sonar.tests", "${webappDir}/src"
property "sonar.test.inclusions", "**/*.spec.ts"
property "sonar.ts.tslint.configPath", distDir
property "sonar.ts.tslint.projectPath", distDir
property "sonar.ts.tslint.outputPath", "${project.buildDir}/node/coverage/tslint_out_mapped.json"
property "sonar.ts.coverage.lcovReportpath", "${project.buildDir}/node/coverage/lcov.info"
}
}
node {
version = '16.16.0'
npmVersion = '8.15.0'
distBaseUrl = 'https://nodejs.org/dist'
download = true
npmInstallCommand = 'ci'
workDir = file("${project.buildDir}/node/nodejs")
npmWorkDir = file("${project.buildDir}/node")
nodeModulesDir = file(webappDir)
}
task copyUserGuide(type: Copy) {
from project(':doc:UserGuide').files('docs')
into 'src/main/webapp/src/assets/docs/'
}
task copyGettingStarted(type: Copy) {
from project(':doc:GettingStartedGuide').files('docs')
into 'src/main/webapp/src/assets/docs/'
}
task runTest(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'ci_test']
inputs.files("${webappDir}/package.json", "${webappDir}/package-lock.json", "${webappDir}/angular.json", "${webappDir}/tsconfig.json", "${webappDir}/tsconfig.*.json")
inputs.dir(fileTree("${webappDir}/src"))
inputs.dir(fileTree("${webappDir}/node_modules").exclude(".cache"))
outputs.dir(distDir)
}
task runBuild(type: NpmTask) {
dependsOn npmInstall
dependsOn copyUserGuide
dependsOn copyGettingStarted
//dependsOn runTest // TODO: depend on 'runTest' again as soon as chrome is available in the build environment
args = ['run', 'build', "--", "--output-path=${distDir}", "--progress=false"]
inputs.files("${webappDir}/package.json", "${webappDir}/package-lock.json", "${webappDir}/angular.json", "${webappDir}/tsconfig.json", "${webappDir}/tsconfig.app.json", "${webappDir}/tsconfig.spec.json")
inputs.dir(fileTree("${webappDir}/src"))
inputs.dir(fileTree("${webappDir}/node_modules").exclude(".cache"))
outputs.dir(distDir)
}
jar {
dependsOn runBuild
metaInf {
from('../../') {
include 'NOTICE.txt'
include 'LICENSE.txt'
}
}
metaInf {
from (distDir)
into 'resources'
}
}
clean.doLast {
file("${webappDir}/node_modules").deleteDir()
file("${webappDir}/coverage").deleteDir()
}