Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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)}")
- }
- }
- }
- /**
- * 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 ->
- println("Looking for ${file} in ${folder}")
- if (Paths.get( "${folder}${File.separator}${file}").toFile().exists()){
- println("Found ${file} in ${folder}")
- return true
- }
- }
- return fileFound
- }
- // Making test task to depend on checkEnv
- test.dependsOn checkEnv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement