From a3c328d173e8fa64968ac45bdd02844ba5bec7b9 Mon Sep 17 00:00:00 2001 From: Joaquim Alvino de Mesquita Neto Date: Wed, 5 Jan 2022 15:42:17 +0100 Subject: [PATCH] changed dotnet executable args order --- build.gradle | 4 +- .../BuildSolutionTaskIntegrationSpec.groovy | 44 +++++++++++++++---- .../dotnetsonar/tasks/internal/DotNet.groovy | 2 +- .../tasks/internal/DotNetSpec.groovy | 2 +- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 79e4820..8a37b1f 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ plugins { - id 'net.wooga.plugins' version '2.2.1' //needs git repository with filled HEAD (at least one commit) + id 'net.wooga.plugins' version '2.2.3' } group 'net.wooga.gradle' @@ -52,7 +52,7 @@ dependencies { api 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.2.0' implementation 'gradle.plugin.net.wooga.gradle:atlas-github:2.+' testImplementation 'com.wooga.spock.extensions:spock-github-extension:0.2.0' - testImplementation 'org.ajoberstar.grgit:grgit-core:4.1.0' + testImplementation 'org.ajoberstar.grgit:grgit-core:4.+' } configurations.all { diff --git a/src/integrationTest/groovy/wooga/gradle/dotnetsonar/tasks/BuildSolutionTaskIntegrationSpec.groovy b/src/integrationTest/groovy/wooga/gradle/dotnetsonar/tasks/BuildSolutionTaskIntegrationSpec.groovy index 8443cb9..525076f 100644 --- a/src/integrationTest/groovy/wooga/gradle/dotnetsonar/tasks/BuildSolutionTaskIntegrationSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/dotnetsonar/tasks/BuildSolutionTaskIntegrationSpec.groovy @@ -19,13 +19,13 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec { } @Unroll - def "Builds a C# solution with #tool #subtool command"() { + def "Builds a C# solution with dotnet #subtool #extraArgs command"() { given: "a msbuild executable" - def fakeBuildExec = argReflectingFakeExecutable(tool, 0) + def fakeBuildExec = argReflectingFakeExecutable("dotnet", 0) and: "build file with configured task" buildFile << """ project.tasks.create("solutionBuild", ${BuildSolution.name}) { - ${tool}Executable = ${wrapValueBasedOnType(fakeBuildExec.absolutePath, File)} + dotnetExecutable = ${wrapValueBasedOnType(fakeBuildExec.absolutePath, File)} solution = ${wrapValueBasedOnType(solutionPath, File)} environment = ${wrapValueBasedOnType(environment, Map)} extraArgs = ${wrapValueBasedOnType(extraArgs, List)} @@ -36,15 +36,41 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec { then: def buildResult = executionResults(fakeBuildExec, result) - buildResult.args == subtool + extraArgs + [Paths.get(projectDir.absolutePath, solutionPath).toString()] + buildResult.args == subtool + [Paths.get(projectDir.absolutePath, solutionPath).toString()] + extraArgs buildResult.envs.entrySet().containsAll(environment.entrySet()) where: - tool | solutionPath | subtool | environment | extraArgs - "msBuild" | "solution.sln" | [] | ["a": "b"] | [] - "msBuild" | "solution.sln" | [] | [:] | ["-arg", "/arg:value"] - "dotnet" | "dir/solution.sln" | ["build"] | [:] | [] - "dotnet" | "dir/solution.sln" | ["build"] | ["b": "c"] | ["-arg", "/arg:value"] + solutionPath | subtool | environment | extraArgs + "dir/solution.sln" | ["build"] | [:] | [] + "dir/solution.sln" | ["build"] | ["b": "c"] | ["-arg", "/arg:value"] + } + + + @Unroll + def "Builds a C# solution with msbuild #extraArgs command"() { + given: "a msbuild executable" + def fakeBuildExec = argReflectingFakeExecutable("msBuild", 0) + and: "build file with configured task" + buildFile << """ + project.tasks.create("solutionBuild", ${BuildSolution.name}) { + msBuildExecutable = ${wrapValueBasedOnType(fakeBuildExec.absolutePath, File)} + solution = ${wrapValueBasedOnType(solutionPath, File)} + environment = ${wrapValueBasedOnType(environment, Map)} + extraArgs = ${wrapValueBasedOnType(extraArgs, List)} + } + """ + when: + def result = runTasksSuccessfully("solutionBuild") + + then: + def buildResult = executionResults(fakeBuildExec, result) + buildResult.args == extraArgs + [Paths.get(projectDir.absolutePath, solutionPath).toString()] + buildResult.envs.entrySet().containsAll(environment.entrySet()) + + where: + solutionPath | environment | extraArgs + "solution.sln" | ["a": "b"] | [] + "solution.sln" | [:] | ["-arg", "/arg:value"] } @Unroll diff --git a/src/main/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNet.groovy b/src/main/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNet.groovy index 15efb7e..43438f1 100644 --- a/src/main/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNet.groovy +++ b/src/main/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNet.groovy @@ -22,8 +22,8 @@ class DotNet implements SolutionBuildTool { execSpec.executable = executable.absolutePath execSpec.environment(environment) execSpec.args("build") - execSpec.args(*extraArgs) execSpec.args(solution.absolutePath) + execSpec.args(*extraArgs) }.throwsOnFailure() } diff --git a/src/test/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNetSpec.groovy b/src/test/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNetSpec.groovy index b318010..6ee8fbe 100644 --- a/src/test/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNetSpec.groovy +++ b/src/test/groovy/wooga/gradle/dotnetsonar/tasks/internal/DotNetSpec.groovy @@ -22,7 +22,7 @@ class DotNetSpec extends Specification { then: shell.lastExecSpec.executable == executable.absolutePath - shell.lastExecSpec.args == ["build"] + extraArgs + [solution.absolutePath] + shell.lastExecSpec.args == ["build"] + [solution.absolutePath] + extraArgs shell.lastExecSpec.environment.entrySet().containsAll(environment.entrySet()) where: