Add a recursive sbt.IO.listFiles
See original GitHub issueAs of SBT 0.13.7, there doesn’t appear to be a way to recursively list files in a directory using the provided sbt.IO.listFiles
helper functions. Essentially I want an sbt.IO.listFiles
that lists all files within a given directory, and optionally all of its subdirectories.
http://www.scala-sbt.org/0.13.7/api/index.html#sbt.IO$
When needed, I end up doing something like this peppered around several build definitions:
def listFilesRecursively(dir: File): Seq[File] = {
val list = sbt.IO.listFiles(dir)
list.filter(_.isFile) ++ list.filter(_.isDirectory).flatMap(listFilesRecursively)
}
It would be great if SBT could fold this into sbt.IO
— either by creating a new function named listFilesRecursively
, or add an optional recursive:Boolean = false
argument to the existing sbt.IO.listFiles
functions which one could set to true
to make them recursive as needed.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How do I list all files in a subdirectory in scala? - Stack Overflow
os-lib is the easiest way to recursively list files in Scala. os.walk(os.
Read more >How to list files in a directory in Scala (and filter the list)
Using Scala, you want to get a list of files that are in a directory, potentially limiting the list of files with a...
Read more >Java File IO - List files and directories recursively - CodeJava.net
Java File IO - List files and directories recursively · If the file is a directory: Print out directory name. Repeat the step...
Read more >IO - sbt.io.IO - javadoc.io
def append(file: File, content: String, charset: Charset ... Deletes each file or directory (recursively) in files . ... def listFiles(filter: java.io.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just in case anyone comes across this,
Path.allSubpaths
sbt also has Paths, which is pretty versatile. What you’re after could be written as:
or more concisely as: