Support running executable Gradle tasks on Windows with WSL (#6803)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/6814/head
Fabio Di Fabio 8 months ago committed by GitHub
parent 2222bb197b
commit 02dd244233
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 41
      build.gradle
  2. 2
      wslsh.bat

@ -89,6 +89,9 @@ def _strListCmdArg(name) {
return _strListCmdArg(name, null) return _strListCmdArg(name, null)
} }
// set the shell command to use according to os
def shell = org.gradle.internal.os.OperatingSystem.current().isWindows() ? "${projectDir}\\wslsh.bat" : '/bin/bash'
licenseReport { licenseReport {
// This is for the allowed-licenses-file in checkLicense Task // This is for the allowed-licenses-file in checkLicense Task
// Accepts File, URL or String path to local or remote file // Accepts File, URL or String path to local or remote file
@ -760,7 +763,7 @@ task distDocker {
println "Building for platform ${project.getProperty('docker-platform')}" println "Building for platform ${project.getProperty('docker-platform')}"
} }
def gitDetails = getGitCommitDetails(10) def gitDetails = getGitCommitDetails(10)
executable "sh" executable shell
workingDir dockerBuildDir workingDir dockerBuildDir
args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${gitDetails.hash} -t ${image} ." args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${gitDetails.hash} -t ${image} ."
} }
@ -768,12 +771,12 @@ task distDocker {
// tag the "default" (which is the variant in the zero position) // tag the "default" (which is the variant in the zero position)
exec { exec {
executable "sh" executable shell
args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:${dockerBuildVersion}'" args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:${dockerBuildVersion}'"
} }
// create a static tag for the benchmark target // create a static tag for the benchmark target
exec { exec {
executable "sh" executable shell
args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:benchmark'" args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:benchmark'"
} }
} }
@ -792,8 +795,8 @@ task testDocker {
exec { exec {
def image = project.hasProperty('release.releaseVersion') ? "${dockerImageName}:" + project.property('release.releaseVersion') : "${dockerImageName}:${project.version}" def image = project.hasProperty('release.releaseVersion') ? "${dockerImageName}:" + project.property('release.releaseVersion') : "${dockerImageName}:${project.version}"
workingDir "${projectDir}/docker/${variant}" workingDir "${projectDir}/docker/${variant}"
executable "sh" executable shell
args "-c", "bash ../test.sh ${image}-${variant}" args "-c", "../test.sh ${image}-${variant}"
} }
} }
} }
@ -821,7 +824,7 @@ task dockerUpload {
def cmd = "docker tag '${variantImage}' '${archVariantImage}' && docker push '${archVariantImage}'" def cmd = "docker tag '${variantImage}' '${archVariantImage}' && docker push '${archVariantImage}'"
additionalTags.each { tag -> cmd += " && docker tag '${variantImage}' '${dockerImageName}:${tag.trim()}-${variant}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${variant}-${architecture}'" } additionalTags.each { tag -> cmd += " && docker tag '${variantImage}' '${dockerImageName}:${tag.trim()}-${variant}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${variant}-${architecture}'" }
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }
@ -831,7 +834,7 @@ task dockerUpload {
def cmd = "docker tag ${image} ${archImage} && docker push '${archImage}'" def cmd = "docker tag ${image} ${archImage} && docker push '${archImage}'"
additionalTags.each { tag -> cmd += " && docker tag '${image}' '${dockerImageName}:${tag.trim()}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${architecture}'" } additionalTags.each { tag -> cmd += " && docker tag '${image}' '${dockerImageName}:${tag.trim()}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${architecture}'" }
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }
@ -848,13 +851,13 @@ task dockerUploadRelease {
exec { exec {
def cmd = "docker pull '${variantImage}-${architecture}' && docker tag '${variantImage}-${architecture}' '${dockerImageName}:latest-${variant}-${architecture}'" def cmd = "docker pull '${variantImage}-${architecture}' && docker tag '${variantImage}-${architecture}' '${dockerImageName}:latest-${variant}-${architecture}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
exec { exec {
def cmd = "docker push '${dockerImageName}:latest-${variant}-${architecture}'" def cmd = "docker push '${dockerImageName}:latest-${variant}-${architecture}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }
@ -863,13 +866,13 @@ task dockerUploadRelease {
def archImage = "${image}-${architecture}" def archImage = "${image}-${architecture}"
def cmd = "docker pull '${archImage}' && docker tag ${archImage} '${dockerImageName}:latest-${architecture}'" def cmd = "docker pull '${archImage}' && docker tag ${archImage} '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
exec { exec {
def cmd = "docker push '${dockerImageName}:latest-${architecture}'" def cmd = "docker push '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }
@ -899,13 +902,13 @@ task manifestDocker {
exec { exec {
def cmd = "docker manifest create '${variantImage}' ${targets}" def cmd = "docker manifest create '${variantImage}' ${targets}"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
exec { exec {
def cmd = "docker manifest push '${variantImage}'" def cmd = "docker manifest push '${variantImage}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }
@ -915,13 +918,13 @@ task manifestDocker {
archs.forEach { arch -> targets += "'${baseTag}-${arch}' " } archs.forEach { arch -> targets += "'${baseTag}-${arch}' " }
def cmd = "docker manifest create '${baseTag}' ${targets}" def cmd = "docker manifest create '${baseTag}' ${targets}"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
exec { exec {
def cmd = "docker manifest push '${baseTag}'" def cmd = "docker manifest push '${baseTag}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }
@ -941,13 +944,13 @@ task manifestDockerRelease {
exec { exec {
def cmd = "docker manifest create '${variantImage}' ${targets} --amend" def cmd = "docker manifest create '${variantImage}' ${targets} --amend"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
exec { exec {
def cmd = "docker manifest push '${variantImage}'" def cmd = "docker manifest push '${variantImage}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }
@ -957,13 +960,13 @@ task manifestDockerRelease {
archs.forEach { arch -> targets += "'${baseTag}-${arch}' " } archs.forEach { arch -> targets += "'${baseTag}-${arch}' " }
def cmd = "docker manifest create '${baseTag}' ${targets} --amend" def cmd = "docker manifest create '${baseTag}' ${targets} --amend"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
exec { exec {
def cmd = "docker manifest push '${baseTag}'" def cmd = "docker manifest push '${baseTag}'"
println "Executing '${cmd}'" println "Executing '${cmd}'"
executable "sh" executable shell
args "-c", cmd args "-c", cmd
} }
} }

@ -0,0 +1,2 @@
set WSLENV=architecture/u
wsl /bin/bash %*
Loading…
Cancel
Save