Skip to content

Commit

Permalink
Revert "Fix jackson java version issue (#53)" (#54)
Browse files Browse the repository at this point in the history
This reverts commit a17c12b.
  • Loading branch information
Joaquimmnetto authored Aug 6, 2024
1 parent a17c12b commit db66e0e
Show file tree
Hide file tree
Showing 44 changed files with 1,334 additions and 1,167 deletions.
10 changes: 0 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ gradlePlugin {
description = 'This plugin provides tools to run sonarqube scans for .NET solutions'
implementationClass = 'wooga.gradle.dotnetsonar.DotNetSonarqubePlugin'
}
unitySonarqube {
id = 'net.wooga.unity-sonarqube'
displayName = 'Sonarqube plugin for wooga unity projects'
description = 'This plugin provides tools to run sonarqube scans for .NET unity solutions'
implementationClass = 'wooga.gradle.unitysonar.UnitySonarqubePlugin'
}
}
}

Expand All @@ -66,11 +60,7 @@ github {

dependencies {
api 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.2.0'
implementation 'net.wooga.gradle:dotnet:0.3.0'
implementation 'net.wooga.gradle:github:[3,4['
implementation 'net.wooga.gradle:unity:[4,5['
implementation 'net.wooga.gradle:asdf:[1,2['
testImplementation 'com.wooga.spock.extensions:spock-github-extension:0.4.0'
testImplementation 'org.ajoberstar.grgit:grgit-core:4.+'
testImplementation 'com.wooga.gradle:gradle-commons-test:[2,3)'
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@

package wooga.gradle.dotnetsonar

import com.wooga.gradle.test.executable.FakeExecutables
import spock.lang.Unroll
import wooga.gradle.dotnetsonar.tasks.internal.SonarScannerInstaller
import wooga.gradle.dotnetsonar.tasks.utils.PluginIntegrationSpec
import wooga.gradle.dotnetsonar.utils.SpecFakes

import static wooga.gradle.dotnetsonar.utils.SpecUtils.wasExecutedAfter
import static wooga.gradle.dotnetsonar.utils.SpecUtils.wasExecutedBefore
import static wooga.gradle.dotnetsonar.tasks.internal.SonarScannerInstaller.defaultBaseURL
import static wooga.gradle.dotnetsonar.utils.SpecUtils.*
import static wooga.gradle.dotnetsonar.utils.SpecUtils.wrapValueBasedOnType


class SonarScannerExtensionIntegrationSpec extends PluginIntegrationSpec {

def "registers custom build task for sonar scanner"() {
given: "a sonar scanner executable"
def fakeScanner = FakeExecutables.argsReflector("sonarscanner", 0)
given: "a sonnar scanner executable"
File fakeScannerExec = SpecFakes.argReflectingFakeExecutable("sonarscanner")
and: "custom task registering itself on sonar scanner extension"
buildFile << """
${forceAddObjectsToExtension(fakeScanner.executable)}
${forceAddObjectsToExtension(fakeScannerExec)}
${getSonarScannerExtension("sonarScannerExt")}
tasks.register("custom") {
sonarScanner.registerBuildTask(it)
sonarScannerExt.registerBuildTask(it)
}
"""
when: "executing custom task"
Expand All @@ -52,37 +56,33 @@ class SonarScannerExtensionIntegrationSpec extends PluginIntegrationSpec {
and: "unset sonarScannerExecutable property in the extension"

when: "running tasks dependent on sonar scanner executable"
def result = runTasks("sonarScannerBegin")
runTasks("sonarScannerBegin")

then: "dotnet sonar scanner package should be installed at default directory"
result.wasExecuted(":installSonarScanner")
def defaultInstallDir = "build/bin/net-sonarscanner/${defaultVersion}-netcoreapp2.0"
new File(projectDir, "${defaultInstallDir}/${SonarScannerInstaller.DLL_NAME}").exists()

where:
defaultVersion = DotNetSonarqubePluginConventions.scannerInstallVersion.defaultValue.toString()
def defaultInstallDir = "build/bin/net-sonarscanner/"
new File(projectDir,
"${defaultInstallDir}/${SonarScannerInstaller.EXECUTABLE_NAME}").exists()
}

@Unroll
def "installs sonar scanner version #version-netcoreapp2.0 in #installDir"() {
def "installs sonar scanner version #version-net46 in #installDir"() {
given: "installed dotnet sonarscanner plugin"
and: "no pre-existent sonarscanner executable on PATH"
and: "configured sonar scanner extension"
buildFile << """
sonarScanner {
installInfo {
version = "${version}"
installDir = ${wrapValueBasedOnType(installDir, File)}
installDir = "${installDir}"
}
}
"""
when: "running tasks dependent on sonar scanner executable"
def result = runTasks("sonarScannerBegin")
runTasks("sonarScannerBegin")

then: "dotnet sonar scanner package should be installed at default directory"
result.wasExecuted(":installSonarScanner")
new File(projectDir,
"${installDir}/${SonarScannerInstaller.DLL_NAME}").exists()
"${installDir}/${SonarScannerInstaller.EXECUTABLE_NAME}").exists()
where:
version | installDir
"5.2.2.33595" | "bin/fdlr"
Expand All @@ -98,16 +98,15 @@ class SonarScannerExtensionIntegrationSpec extends PluginIntegrationSpec {
buildFile << """
sonarScanner {
installInfo {
installURL = "${url}"
installDir = ${wrapValueBasedOnType(installDir, File)}
sourceURL = "${url}"
installDir = "${installDir}"
}
}
"""
when: "running tasks dependent on sonar scanner executable"
def result = runTasks("sonarScannerBegin")
runTasks("sonarScannerBegin")

then: "dotnet sonar scanner package should be installed at default directory"
result.wasExecuted(":installSonarScanner")
new File(projectDir,
"${installDir}/${SonarScannerInstaller.EXECUTABLE_NAME}").exists()
where:
Expand All @@ -119,21 +118,20 @@ class SonarScannerExtensionIntegrationSpec extends PluginIntegrationSpec {
def "doesn't install sonar scanner if executable already exists on extension"() {
given: "installed dotnet sonarscanner plugin"
and: "pre-existent sonarscanner executable"
def sonarScannerExec = FakeExecutables.argsReflector("sonarscanner.bat", 0)
def sonarScannerExec = SpecFakes.argReflectingFakeExecutable("sonarscanner.bat")
buildFile << """
sonarScanner {
sonarScannerExecutable = ${wrapValueBasedOnType(sonarScannerExec.executable.absolutePath, File)}
sonarScannerExecutable = ${wrapValueBasedOnType(sonarScannerExec.absolutePath, File)}
installInfo {
version = "5.2.1.31210"
}
}
"""

when: "running tasks dependent on sonar scanner executable"
def result = runTasks("sonarScannerBegin")
runTasks("sonarScannerBegin")

then: "sonar scanner should not be downloaded"
result.standardOutput.contains(":installSonarScanner SKIPPED")
def defaultInstallDir = "build/bin/net-sonarscanner/"
!new File(projectDir,
"${defaultInstallDir}/${SonarScannerInstaller.EXECUTABLE_NAME}").exists()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,28 @@

package wooga.gradle.dotnetsonar.tasks

import com.wooga.gradle.test.executable.FakeExecutables
import org.gradle.api.GradleException
import org.gradle.process.internal.ExecException
import spock.lang.Unroll
import wooga.gradle.dotnetsonar.tasks.utils.PluginIntegrationSpec

import java.nio.file.Paths

import static wooga.gradle.dotnetsonar.utils.FakeExecutable.executionResults
import static wooga.gradle.dotnetsonar.utils.SpecFakes.argReflectingFakeExecutable
import static wooga.gradle.dotnetsonar.utils.SpecUtils.rootCause
import static wooga.gradle.dotnetsonar.utils.SpecUtils.wrapValueBasedOnType

class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec {

def setup() {
def fakeSonarScanner = FakeExecutables.argsReflector("sonarscanner", 0)
buildFile << forceAddObjectsToExtension(fakeSonarScanner.executable)
def fakeSonarScannerExec = argReflectingFakeExecutable("sonarscanner", 0)
buildFile << forceAddObjectsToExtension(fakeSonarScannerExec)
}

@Unroll
def "Builds a C# solution with dotnet #subtool #extraArgs command"() {
given: "a msbuild executable"
def fakeBuild = FakeExecutables.argsReflector("dotnet-build", 0)
def fakeBuildExec = argReflectingFakeExecutable("dotnet", 0)
and: "fake solution file"
new File(projectDir, solutionPath).with {
parentFile.mkdirs()
Expand All @@ -45,19 +46,18 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec {
and: "build file with configured task"
buildFile << """
project.tasks.create("solutionBuild", ${BuildSolution.name}) {
executable = ${wrapValueBasedOnType(fakeBuild.executable.absolutePath, File)}
dotnetExecutable = ${wrapValueBasedOnType(fakeBuildExec.absolutePath, File)}
solution = ${wrapValueBasedOnType(solutionPath, File)}
environment = ${wrapValueBasedOnType(environment, Map)}
additionalArguments.addAll(${wrapValueBasedOnType(extraArgs, List)})
extraArgs = ${wrapValueBasedOnType(extraArgs, List)}
}
"""
when:
def result = runTasksSuccessfully("solutionBuild")

then:
def buildResult = fakeBuild.firstResult(result.standardOutput)
def args = [Paths.get(projectDir.absolutePath, solutionPath).toString()] + extraArgs
buildResult.args == subtool + args
def buildResult = executionResults(fakeBuildExec, result)
buildResult.args == subtool + [Paths.get(projectDir.absolutePath, solutionPath).toString()] + extraArgs
buildResult.envs.entrySet().containsAll(environment.entrySet())

where:
Expand All @@ -66,10 +66,43 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec {
"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: "fake solution file"
new File(projectDir, solutionPath).with {
parentFile.mkdirs()
createNewFile()
}
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
def "BuildSolution task fails if tool returns non-zero status"() {
def "#tool build task fails if tool returns non-zero status"() {
given: "a build executable"
def fakeDotnet = FakeExecutables.argsReflector("dotnet", 1)
def fakeMsBuildExec = argReflectingFakeExecutable(tool, 1)
and: "fake solution file"
new File(projectDir, solutionPath).with {
parentFile.mkdirs()
Expand All @@ -78,7 +111,7 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec {
and: "build file with configured task"
buildFile << """
project.tasks.create("solutionBuild", ${BuildSolution.name}) {
executable = ${wrapValueBasedOnType(fakeDotnet.executable.absolutePath, File)}
${tool}Executable = ${wrapValueBasedOnType(fakeMsBuildExec.absolutePath, File)}
solution = ${wrapValueBasedOnType(solutionPath, File)}
}
"""
Expand All @@ -87,9 +120,11 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec {

then: "should fail on execution with non-zero exit value"
def e = rootCause(result.failure)
e.getClass().name == GradleException.name
e.getClass().name == ExecException.name
e.message.contains(fakeMsBuildExec.absolutePath)
e.message.contains("exit value 1")
where:
tool << ["msBuild", "dotnet"]
solutionPath = "solution.sln"
}
}
Loading

0 comments on commit db66e0e

Please sign in to comment.