From 1e76d7d9c8c0e97d5a531fb6d473b5c94e1befaf Mon Sep 17 00:00:00 2001 From: Adam Wheeler Date: Wed, 19 Feb 2020 09:52:35 -0500 Subject: [PATCH] Using the R_HOME environmental variable Using the R_HOME environmental variable if it is available. would be helpful in systems installed with multiple versions. I didnt see another place to set it, unless I missed something. So I am proposing this change. THIS CHANGE IS NOT TESTED. --- .../src/main/groovy/com/umayrh/gradle/RScriptTask.groovy | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/groovy/com/umayrh/gradle/RScriptTask.groovy b/plugin/src/main/groovy/com/umayrh/gradle/RScriptTask.groovy index 2debdeb..5e0c577 100644 --- a/plugin/src/main/groovy/com/umayrh/gradle/RScriptTask.groovy +++ b/plugin/src/main/groovy/com/umayrh/gradle/RScriptTask.groovy @@ -17,6 +17,7 @@ class RScriptTask extends DefaultTask { @Input String expression = null + @TaskAction def exec() { @@ -24,8 +25,14 @@ class RScriptTask extends DefaultTask { if (expression == null) { throw new GradleException("Must specify an Rscript expression") } + def env = System.getenv()['R_HOME'] + if (env == null) { + // commandLine is part of Exec task + commandLine 'Rscript', '-e', expression + }else{ // commandLine is part of Exec task - commandLine 'Rscript', '-e', expression + commandLine env +'/bin/Rscript', '-e', expression + } } } }