io.openapiprocessor.test.Collector.groovy Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2020 https://github.com/openapi-processor/openapi-processor-test
* PDX-License-Identifier: Apache-2.0
*/
package io.openapiprocessor.test
import java.nio.file.Files
import java.nio.file.Path
class Collector {
/**
* collect paths in source path.
*
* @param source source path
* will convert all paths to use "/" as path separator
*/
static List collectPaths(Path source) {
List files = []
def found = Files.walk (source)
.filter ({ f ->
!Files.isDirectory (f)
})
found.forEach ({f ->
files << source.relativize (f).toString ()
})
found.close ()
files.collect {
it.replace ('\\', '/')
}
}
}