I have dir in which another task create files and directories so in this dir there are files, directories, subdirectroies, files in them and ect. I want to put all absolute path of files and directories in a list.
def listNames = project.fileTree('dir')
But only the files are included in the list, directories are missing. How to collect all of them?
Gradle uses the name build. gradle as the default name for a build file. If we write our build code in a file build. gradle then we don't have to specify the build filename when we run tasks.
The Gradle user home directory ( $USER_HOME/.gradle by default) is used to store global configuration properties and initialization scripts as well as caches and log files.
get global build path from environment variable or fallback to build directory inside project directory; include project group in path, this makes path more unique especially if you have several projects with the same name.
gradle file is located in each module of the android project. This file includes your package name as applicationID , version name(apk version), version code, minimum and target sdk for a specific application module.
def names = []
fileTree("baseDir").visit { FileVisitDetails details ->
names << details.file.path
}
For further details, see FileTree
in the Gradle Javadoc.
The shorter version:
def files = fileTree("dirName").filter { it.isFile() }.files.name
Of course it does the same thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With