{"id":21981789,"url":"https://github.com/gmullerb/file-lister","last_synced_at":"2026-05-01T17:33:03.035Z","repository":{"id":96572585,"uuid":"151171735","full_name":"gmullerb/file-lister","owner":"gmullerb","description":"Small set of utilities for listing files from a Gradle project","archived":false,"fork":false,"pushed_at":"2019-09-02T19:05:57.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-19T17:05:58.696Z","etag":null,"topics":["directory","excluding","excluding-file","excluding-folder","file","filesystem","filetree","filter","filter-plugin","folder","gitignore","gradle","gradle-plugin","gradle-project","ignore-files","including","including-file","including-folder","listing-files","node-modules"],"latest_commit_sha":null,"homepage":null,"language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmullerb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-01T22:57:36.000Z","updated_at":"2019-09-02T19:05:59.000Z","dependencies_parsed_at":"2023-04-22T22:58:49.448Z","dependency_job_id":null,"html_url":"https://github.com/gmullerb/file-lister","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Ffile-lister","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Ffile-lister/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Ffile-lister/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Ffile-lister/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmullerb","download_url":"https://codeload.github.com/gmullerb/file-lister/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245041137,"owners_count":20551363,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directory","excluding","excluding-file","excluding-folder","file","filesystem","filetree","filter","filter-plugin","folder","gitignore","gradle","gradle-plugin","gradle-project","ignore-files","including","including-file","including-folder","listing-files","node-modules"],"created_at":"2024-11-29T17:19:39.246Z","updated_at":"2026-05-01T17:33:02.987Z","avatar_url":"https://github.com/gmullerb.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File lister\n\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](/LICENSE.txt) [![Download](https://api.bintray.com/packages/gmullerb/all.shared.gradle/file-lister/images/download.svg)](https://bintray.com/gmullerb/all.shared.gradle/file-lister/_latestVersion) [![coverage report](https://gitlab.com/gmullerb/file-lister/badges/master/coverage.svg)](https://gitlab.com/gmullerb/project-style-checker/commits/master)\n\n**File lister offers a small set of utilities for listing files to Gradle projects.**\n\nThis project is licensed under the terms of the [MIT license](/LICENSE.txt).\n__________________\n\n## Quick Start\n\n1 . Apply the plugin:\n\n`build.gradle`:\n\n```gradle\n plugins {\n   id 'all.shared.gradle.file-lister' version '1.0.2'\n }\n```\n\n2 . Use `fileLister` methods, `obtainPartialFileTree` and/or `obtainFullFileTree`:\n\n`build.gradle`:\n\n```gradle\n  final someFilesInTree = fileLister.obtainPartialFileTree()\n  final allFilesInTree = fileLister.obtainFullFileTree()\n```\n\n3 . Jump to [Using/Configuration](#Using/Configuration), for customization or digging on How it works.\n__________________\n\n## Goal\n\nGet a file tree from a project's specified folder, excluding by default Gradle's files and folders: `**/gradlew.*`, `**/gradle`, `**/.gradle` and `**/build`, excluding by default files and/or folders listed in the `.gitignore`'s files found in the folder tree, excluding by default Nodes' folder `**/node_modules`, and optionally excluding and/or including a set of custom ANT patterns.\n\n## Features\n\nBasically offers a small set of functions:\n\n* `ConfigurableFileTree obtainFullFileTree(folder, [excludes:[..], includes:[..]])`: A function for recursively listing all files and/or folders from a project's specified folder, excluding and/or including a set of custom ANT patterns.\n* `ConfigurableFileTree obtainPartialFileTree(folder, [excludes:[..], includes:[..]])`: A function for recursively listing all files and/or folders from a project's specified folder, excluding and/or including a set of custom ANT patterns and excluding files listed in the `.gitignore`'s files found in the folder tree.\n\nWhen using the core `fileTree` method, it excludes some file/folders by default[1], mainly commanded by ANT, e.g.: `**/.cvsignore`, `**/.git`, `**/.gitignore`, `**/.svn`, etc; that is good, but this plugin provides:\n\n* Additional exclusions based on Gradle: `**/.gradle` and `**/gradle-wrapper.jar`.\n* Also one of the methods, `obtainPartialFileTree`, additionally excludes by default files/folders taking in account also the `.gitignore` files information (which is what is not sent from the project to the repository, what usually means that is not relevant to the project).\n  * Git patterns containing `!`,`[` \u0026 `]` are not considered by the plugin.\n\nE.g.[2]:\n\nGiven the following folder structure:\n\n```\n  .gitignore\n  /.git\n    file1.ext1\n  /folderA\n    file1.ext1\n    file1.ext3\n    /gradle\n      file1.ext1\n  /folderB\n    .gitignore\n     file1.ext1\n     file1.ext2\n     file1.ext3\n    /node_modules\n      file1.ext1\n```\n\n* With `/.gitignore` having: `*.ext2`\n* With `/folderB/.gitignore` having: `*.ext3`\n\nThe result will be:\n\n* When using `fileTree()`: `/folderA/file1.ext1`, `/folderA/file1.ext3`, `/folderA/gradle/file1.ext1`, `/folderB/file1.ext1`, `/folderB/file1.ext2`, `/folderB/file1.ext3` and `/folderB/node_modules/file1.ext1`\n* When using `obtainFullFileTree)`: `/folderA/file1.ext1`, `/folderA/file1.ext3`, `/folderB/file1.ext1`, `/folderB/file1.ext2` and `/folderB/file1.ext3`\n* When using `obtainPartialFileTree()`: `/folderA/file1.ext1`, `/folderA/file1.ext3` and `/folderB/file1.ext1`\n\n\u003e [1] [All ANT default excludes](https://ant.apache.org/manual/dirtasks.html#defaultexcludes).  \n\u003e [2] For an actual use example, see [basecode project](https://github.com/gmullerb/basecode).\n__________________\n\n## Using/Configuration\n\n### Prerequisites\n\n* None\n\n### Gradle configuration\n\n1. Apply the plugin:\n\n```gradle\n plugins {\n   id 'all.shared.gradle.file-lister' version '1.0.2'\n }\n```\n\n2. Use the plugin, it will add a property named `fileLister` to the `Project`:\n\n* Without folder or filters: `final filesInTree = fileLister.obtainPartialFileTree()`, this will walk through project folder.\n* Without filters: `final filesInTree = fileLister.obtainFullFileTree('someFolder')`, this will walk through `someFolder` inside the project folder.\n* Without including: `final filesInTree = fileLister.obtainPartialFileTree('someFolder', [excludes: 'someANTpattern'])`, this will walk through `someFolder` inside the project folder, excluding `someANTpattern` pattern.\n* Without excluding: `final filesInTree = fileLister.obtainFullFileTree('someFolder', [includes: 'someANTpattern'])`, this will walk through `someFolder` inside the project folder, including `someANTpattern` pattern.\n* Without folder: `final filesInTree = fileLister.obtainPartialFileTree('.', [excludes: 'someANTpattern1', includes: 'someANTpattern2'])`, this will walk through project folder, excluding `someANTpattern1` pattern and including `someANTpattern2` pattern [1].\n* With all: `final filesInTree = fileLister.obtainFullFileTree('someFolder', [excludes: 'someANTpattern1', includes: 'someANTpattern2'])`, this will walk through `someFolder`, excluding `someANTpattern1` pattern and including `someANTpattern2` pattern [1].\n\n\u003e [1] `excludes` pattern has precedence over `includes` patterns.\n\n### Using inside a plugin\n\n1 . Add dependency:\n\n```gradle\n  repositories {\n    jcenter()\n    maven {\n      url 'https://plugins.gradle.org/m2/'\n    }\n    maven {\n      url 'https://dl.bintray.com/gmullerb/all.shared.gradle'\n    }\n  }\n\n  dependencies {\n    compile gradleApi()\n    compile 'gradle.plugin.all.shared.gradle.file-lister:file-lister:+'\n  }\n```\n\n2 . Add plugin programmatically:\n\n```gradle\n  import all.shared.gradle.file.FileListerExtension\n  import all.shared.gradle.file.FileListerPlugin\n\n  ..\n\n    if (project.extensions.findByName(FileListerPlugin.EXTENSION_NAME) == null) {\n      plugin.apply(new FileListerPlugin())\n    }\n```\n\n3 . Access `filelister`:\n\n```gradle\n  ..\n  final FileTree result = ((FileListerExtension) project.extensions\n      .findByName(FileListerPlugin.EXTENSION_NAME))\n      .obtainPartialFileTree()\n  result.visit {\n    ..\n  }\n  ..\n```\n__________________\n\n## Extending/Developing\n\n### Prerequisites\n\n* [Java](http://www.oracle.com/technetwork/java/javase/downloads).\n* [Git](https://git-scm.com/downloads) (only if you are going to clone the project).\n\n### Getting it\n\nClone or download the project[1], in the desired folder execute:\n\n```sh\ngit clone https://github.com/gmullerb/file-lister\n```\n\n\u003e [1] [Cloning a repository](https://help.github.com/articles/cloning-a-repository/)\n\n### Set up\n\n* **No need**, only download and run (It's Gradle! Yes!).\n\n### Building it\n\n* To build it:\n  * `gradlew`: this will run default tasks, or\n  * `gradlew build`.\n\n* To assess files:\n  * `gradlew assessCommon`: will check common style of files.\n  * `gradlew assessGradle`: will check code style of Gradle's.\n  * `gradlew assess`: will check code style of Groovy's.\n    * `gradlew codenarcMain`: will check code style of Groovy's source files.\n    * `gradlew codenarcTest`: will check code style of Groovy's test files.\n\n* To test code: `gradlew test`\n  * This task is finalized with a Jacoco Report.\n\n* To get all the tasks for the project: `gradlew tasks --all`\n\n### Folders structure\n\n```\n  /src\n    /main\n      /groovy\n    /test\n      /groovy\n```\n\n- `src/main/groovy`: Source code files.\n  - [`FileListerExtension`](src/main/groovy/all/shared/gradle/file/FileListerExtension.groovy) is where all the magic happens.\n- `src/test/groovy`: Test code files[1].\n\n\u003e [1] Tests are done with [JUnit](http://junit.org) and [Mockito](http://javadoc.io/page/org.mockito/mockito-core/latest/org/mockito/Mockito.html).\n\n### Convention over Configuration\n\nAll `all.shared.gradle` plugins define:\n\n* _PluginName_**Plugin**: which contains the class implements `Plugin` interface.\n* _PluginName_**Extension**: which represent the extension of the plugin.\n* If Tasks are define, then their names will be _TaskName_**Task**.\n* If Actions are define, then their names will be _ActionName_**Action**.\n\nAll `all.shared.gradle` plugins have two **`static`** members:\n\n* `String EXTENSION_NAME`: This will have the name of the extension that the plugin add.\n  * if the plugin does not add an extension the this field will not exist.\n\n* `String TASK_NAME`: This will have the name of the **unique** task that the plugin add.\n  * if the plugin does not add a task or add more than one task, then this field will not exist.\n\n* `boolean complement(final ..)`: will apply the plugin and return true if successful, false otherwise.\n  * this methods is **exactly equivalent to the instance `apply` method**, but without instantiate the class if not required.\n\nBoth may be useful when applying the plugin when creating custom plugins.\n\nAll `all.shared.gradle` plugins \"silently\" fail when the extension can not be added.\n\n## Documentation\n\n* [`CHANGELOG.md`](CHANGELOG.md): add information of notable changes for each version here, chronologically ordered [1].\n\n\u003e [1] [Keep a Changelog](http://keepachangelog.com)\n\n## License\n\n[MIT License](/LICENSE.txt)\n__________________\n\n## Remember\n\n* Use code style verification tools =\u003e Encourages Best Practices, Efficiency, Readability and Learnability.\n* Start testing early =\u003e Encourages Reliability and Maintainability.\n* Code Review everything =\u003e Encourages Functional suitability, Performance Efficiency and Teamwork.\n\n## Additional words\n\nDon't forget:\n\n* **Love what you do**.\n* **Learn everyday**.\n* **Learn yourself**.\n* **Share your knowledge**.\n* **Learn from the past, dream on the future, live and enjoy the present to the max!**.\n\nAt life:\n\n* Let's act, not complain.\n* Be flexible.\n\nAt work:\n\n* Let's give solutions, not questions.\n* Aim to simplicity not intellectualism.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmullerb%2Ffile-lister","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmullerb%2Ffile-lister","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmullerb%2Ffile-lister/lists"}