Last active
April 9, 2019 11:38
-
-
Save mubbashir/821e9327e48ae828b8658626ed0a69b2 to your computer and use it in GitHub Desktop.
Revisions
-
mubbashir revised this gist
Apr 9, 2019 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,11 @@ task("checkEnv"){ } } } /** * Static function to verify if a file/command exist in PATH environment * @param file * @return true if found, else false */ def static isFoundInPath( file){ def PATH_ENV = System.getenv('PATH') def fileFound = PATH_ENV.split(File.pathSeparator).find{ folder -> @@ -21,5 +25,5 @@ def static isFoundInPath( file){ } return fileFound } // Making test task to depend on checkEnv test.dependsOn checkEnv -
mubbashir created this gist
Apr 9, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ // rest of your build // Verfied with gradle 4.10 task("checkEnv"){ doFirst { def listOfFileToCheckInPath = ['find', 'grep'] listOfFileToCheckInPath.each { file -> if(!isFoundInPath(file)) throw new GradleException("${file} was not found in any of the folder in PATH: ${System.getenv('PATH').split(File.pathSeparator)}") } } } def static isFoundInPath( file){ def PATH_ENV = System.getenv('PATH') def fileFound = PATH_ENV.split(File.pathSeparator).find{ folder -> println("Looking for ${file} in ${folder}") if (Paths.get( "${folder}${File.separator}${file}").toFile().exists()){ println("Found ${file} in ${folder}") return true } } return fileFound } test.dependsOn checkEnv