From e792b53ccf010bebc6b5d477476c250183a4be3b Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Fri, 1 Oct 2021 09:57:26 +0200 Subject: [PATCH] [NO-JIRA] Fix Gradle frontend tasks execution on Windows machines --- build.gradle | 13 +++++++++++++ server/sonar-docs/build.gradle | 8 ++++---- server/sonar-web/build.gradle | 8 ++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index b0c8586690f..c03c57edbc6 100644 --- a/build.gradle +++ b/build.gradle @@ -656,3 +656,16 @@ dependencyUpdates { rejected } } + + +ext.osAdaptiveCommand = { commands -> + def newCommands = [] + + if (System.properties['os.name'].toLowerCase().contains('windows')) { + newCommands = ['cmd', '/c'] + } + + newCommands.addAll(commands) + + return newCommands +} \ No newline at end of file diff --git a/server/sonar-docs/build.gradle b/server/sonar-docs/build.gradle index d2c7f745ec8..99c9118ec1c 100644 --- a/server/sonar-docs/build.gradle +++ b/server/sonar-docs/build.gradle @@ -66,7 +66,7 @@ task yarn_run(type: Exec) { outputs.cacheIf { true } environment += [ GATSBY_DOCS_VERSION: docsVersion ] - commandLine 'npm', 'run', 'build' + commandLine osAdaptiveCommand(['npm', 'run', 'build']) } build.dependsOn(yarn_run) @@ -82,7 +82,7 @@ tasks.register("yarn_check-ci", Exec) { inputs.file(it) } - commandLine 'npm', 'run', 'check-ci' + commandLine osAdaptiveCommand(['npm', 'run', 'check-ci']) } tasks.register("yarn_validate-ci", Exec) { @@ -97,7 +97,7 @@ tasks.register("yarn_validate-ci", Exec) { outputs.dir('coverage') outputs.cacheIf { true } - commandLine 'npm', 'run', 'validate-ci' + commandLine osAdaptiveCommand(['npm', 'run', 'validate-ci']) } // Check for known vulnerabilities @@ -106,7 +106,7 @@ task dependency_audit(type: Exec) { outputs.cacheIf { false } ignoreExitValue = true - commandLine 'npm', 'run', 'audit-ci' + commandLine osAdaptiveCommand(['npm', 'run', 'audit-ci']) } task zip(type: Zip) { diff --git a/server/sonar-web/build.gradle b/server/sonar-web/build.gradle index cb081a7c4b4..2ee42455291 100644 --- a/server/sonar-web/build.gradle +++ b/server/sonar-web/build.gradle @@ -22,7 +22,7 @@ task yarn_run(type: Exec) { outputs.dir(webappDir) outputs.cacheIf { true } - commandLine 'npm', 'run', 'build-release' + commandLine osAdaptiveCommand(['npm', 'run', 'build-release']) } build.dependsOn(yarn_run) @@ -38,7 +38,7 @@ tasks.register("yarn_validate-ci", Exec) { outputs.dir('coverage') outputs.cacheIf { true } - commandLine 'npm', 'run', 'validate-ci' + commandLine osAdaptiveCommand(['npm', 'run', 'validate-ci']) } tasks.register("yarn_check-ci", Exec) { @@ -50,7 +50,7 @@ tasks.register("yarn_check-ci", Exec) { inputs.file(it) } - commandLine 'npm', 'run', 'check-ci' + commandLine osAdaptiveCommand(['npm', 'run', 'check-ci']) } // Check for known vulnerabilities @@ -59,7 +59,7 @@ task dependency_audit(type: Exec) { outputs.cacheIf { false } ignoreExitValue = true - commandLine 'npm', 'run', 'audit-ci' + commandLine osAdaptiveCommand(['npm', 'run', 'audit-ci']) } def sources = fileTree(dir: "src") + fileTree(dir: "scripts") + fileTree(dir: "config") + fileTree(dir: "__mocks__") -- 2.39.5