Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add excludeModules option #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ There are other optional configuration below
```gradle
unusedResourcesRemover {
...
// Write module names
excludeModules = [
"example-module", // example-module is never checked
]

// Write file or directory names
excludeNames = [
"strings.xml", // strings.xml is never checked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class UnusedResourcesRemoverExtension {

List<AbstractRemover> extraRemovers = []

List<String> excludeModules = []

List<String> excludeNames = []

boolean dryRun = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class UnusedResourcesRemoverPlugin implements Plugin<Project> {
}
}

if (extension.excludeModules.size() > 0) {
ColoredLogger.log "excludeModules:"
extension.excludeModules.forEach {
ColoredLogger.log " ${it}"
}
}

if (extension.excludeNames.size() > 0) {
ColoredLogger.log "excludeNames:"
extension.excludeNames.forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ abstract class AbstractRemover {
String scanTargetFileTexts = ""

// Extension settings
List<String> excludeModules = []
List<String> excludeNames = []
boolean dryRun = false

Expand All @@ -50,10 +51,12 @@ abstract class AbstractRemover {

void remove(Project project, UnusedResourcesRemoverExtension extension) {
this.dryRun = extension.dryRun
this.excludeModules = extension.excludeModules
this.excludeNames = extension.excludeNames

List<String> moduleSrcDirs = project.rootProject.allprojects
.findAll { it.name != project.rootProject.name }
.findAll { !excludeModules.contains(it.name) }
.collect { "${it.projectDir.path}" }

scanTargetFileTexts = createScanTargetFileTexts(moduleSrcDirs)
Expand Down