gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
92 stars 8 forks source link

environment.path: discrepancy of its name between Windows and Linux/MacOS #898

Open zosrothko opened 5 years ago

zosrothko commented 5 years ago

When running an executable that needs to modify the PATH variable, the build.gradle script should take care about the capitalisation of the path environment variable . On Windows, the path should be named Path while on Linux/MacOSX, it should be named PATH. As consequence, the script should differentiate getting/setting the path according the target platform which IMO should be irrelevant in all cases.

Expected Behavior

One would code

       String PATH = tasks.run.environment.get("PATH")
       tasks.run.environment "PATH", PATH

Current Behavior

One should code

    String PATH = ""
    if (targetPlatform.name.startsWith("win")) 
        PATH = tasks.run.environment.get("Path")
    else
        PATH = tasks.run.environment.get("PATH")

    if (targetPlatform.name.startsWith("win")) 
        tasks.run.environment "Path", PATH
    else
        tasks.run.environment "PATH", PATH

Context

Steps to Reproduce (for bugs)

Your Environment

:\git\poco-1.9.1>gradle\bin\gradle -version


Gradle 4.9-20181009141027+0000

Build time: 2018-10-09 14:10:27 UTC Revision: 0ddd19645cb982956b1d4ea2b71dd8d110741095

Kotlin DSL: 0.18.4 Kotlin: 1.2.41 Groovy: 2.4.12 Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018 JVM: 1.8.0_181 (Oracle Corporation 25.181-b13) OS: Windows 10 10.0 amd64