All Projects → konifar → Gradle Unused Resources Remover Plugin

konifar / Gradle Unused Resources Remover Plugin

Licence: apache-2.0
Gradle Plugin that removes unused resources in Android projects.

Programming Languages

groovy
2714 projects

Projects that are alternatives of or similar to Gradle Unused Resources Remover Plugin

Gradle Aws Plugin
Gradle plugin to manage Amazon Web Services
Stars: ✭ 269 (-4.61%)
Mutual labels:  gradle, gradle-plugin
SetupBuilder
Gradle plugin for building setups for different platforms.
Stars: ✭ 75 (-73.4%)
Mutual labels:  gradle, gradle-plugin
gradle-build-info-plugin
Gradle plugin to include build information such as Git commit ID to your JAR. It can be used to show Git commit information with Spring Boot Actuator.
Stars: ✭ 33 (-88.3%)
Mutual labels:  gradle, gradle-plugin
gradle-cleaner-intellij-plugin
Force clear delaying & no longer needed Gradle tasks.
Stars: ✭ 26 (-90.78%)
Mutual labels:  gradle, gradle-plugin
plugin-yml
A Gradle plugin that generates plugin.yml for Bukkit/BungeeCord/Nukkit plugins based on the Gradle project
Stars: ✭ 42 (-85.11%)
Mutual labels:  gradle, gradle-plugin
sphinx-gradle-plugin
Sphinx site generation plugin for Gradle
Stars: ✭ 19 (-93.26%)
Mutual labels:  gradle, gradle-plugin
gradle-helm-plugin
A Gradle plugin for building, publishing and managing Helm charts.
Stars: ✭ 42 (-85.11%)
Mutual labels:  gradle, gradle-plugin
Maven Git Versioning Extension
This extension will virtually set project versions, based on current git branch or tag.
Stars: ✭ 178 (-36.88%)
Mutual labels:  gradle, gradle-plugin
gradle-libraries-plugin
No description or website provided.
Stars: ✭ 29 (-89.72%)
Mutual labels:  gradle, gradle-plugin
RocketXPlugin
🔥🔥 android 端编译加速插件🚀 自动识别未改动 module 并在编译流程中替换为 aar ,只编译改动模块,加速 Android apk 的编译速度。
Stars: ✭ 408 (+44.68%)
Mutual labels:  gradle, gradle-plugin
schema-registry-plugin
Gradle plugin to interact with Confluent Schema-Registry.
Stars: ✭ 60 (-78.72%)
Mutual labels:  gradle, gradle-plugin
gradle-console-reporter
Gradle plugin to report various kinds of summaries to console.
Stars: ✭ 49 (-82.62%)
Mutual labels:  gradle, gradle-plugin
Badass Jlink Plugin
Create a custom runtime image of your modular application
Stars: ✭ 216 (-23.4%)
Mutual labels:  gradle, gradle-plugin
gradle-localization-plugin
Gradle plugin for automating the download process of localization files.
Stars: ✭ 19 (-93.26%)
Mutual labels:  gradle, gradle-plugin
Gradle Testsets Plugin
A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
Stars: ✭ 182 (-35.46%)
Mutual labels:  gradle, gradle-plugin
gatling-gradle-plugin-demo
Showcase of the Gatling Plugin for Gradle
Stars: ✭ 17 (-93.97%)
Mutual labels:  gradle, gradle-plugin
Click Debounce
Using ASM to handle Android's click debounce, specially a quick double click.
Stars: ✭ 175 (-37.94%)
Mutual labels:  gradle, gradle-plugin
Gradle Launch4j
A gradle-plugin to create windows executables with launch4j
Stars: ✭ 177 (-37.23%)
Mutual labels:  gradle, gradle-plugin
sonatype-publish-plugin
Gradle Plugin for publishing artifacts to Sonatype and Nexus
Stars: ✭ 17 (-93.97%)
Mutual labels:  gradle, gradle-plugin
jooq-plugin
Plugin for generating jOOQ classes using dockerized databases
Stars: ✭ 55 (-80.5%)
Mutual labels:  gradle, gradle-plugin

Unused Resources Remover for Android

CircleCI

Gradle Plugin that removes unused resources in Android projects.

Features

  • Easy to remove unused resources by simple gradle command
  • Customize extra/exclude files configuration
  • Support DataBinding & Multi module project

Simple usage

build.gradle

buildscript {
  repositories {
    maven { url "https://plugins.gradle.org/m2/" }
  }
  
  dependencies {
    classpath "gradle.plugin.com.github.konifar.gradle:plugin:0.3.3"
  }
}

NOTE: If your gradle version is 2.1 and later, you can use new snippet for plugins DSL. If you want to know more details, see plugin page.

app/build.gradle

apply plugin: "com.github.konifar.gradle.unused-resources-remover"

Run

$ ./gradlew removeUnusedResources

Hook to Clean Project(Optional)

If you want to hook to Clean Project, add following code at the end.

app/build.gradle

clean.dependsOn(removeUnusedResources)

Advanced usage

This plugin checks some basic resource files below.

|--res
   |--anim
   |  |--*.xml
   |--animator
   |  |--*.xml
   |--drawable*
   |  |--*.xml
   |  |--*.png
   |  |--*.jpg
   |  |--*.9.png // 9-patch
   |--layout*
   |  |--*.xml
   |--menu
   |  |--*.xml
   |--mipmap*
   |  |--*.xml
   |  |--*.png
   |--values*
      |--attrs*.xml
      |--bools*.xml
      |--colors*.xml
      |--dimens*.xml
      |--floats*.xml
      |--ids*.xml
      |--integers*.xml
      |--strings*.xml
      |--styles*.xml
      |--themes*.xml

If you want to check other files, you can add custom remover settings in app/build.gradle.

Here is two example.

  • fonts.xml (actually same format with strings.xml)
  • text_appearance.xml (actually same format with styles.xml)
unusedResourcesRemover { 
  extraRemovers = [
    createXmlValueRemover("fonts", "string", "string"), // fonts.xml
    createXmlValueRemover("text_appearance", "style", "style", "style") // text_appearance.xml
  ]
  ...
}

There are other optional configuration below

unusedResourcesRemover {
  ...
  // Write file or directory names
  excludeNames = [
    "strings.xml", // strings.xml is never checked
    "res/drawable" // drawable* dirs are never checked
  ]
  
  // When dryRun option is true, unused files are not removed.
  dryRun = true // default false
}

To know more, See UnusedResourcesRemoverExtension

Contributing

This project is under development.

I'm always welcome your contribution! Feel free to report Issue or send Pull Request!

Project structure

plugin/         - The main module of Gradle plugin
example/        - An example android project that uses this plugin
example-module/ - An example module that are used in example

Download repository

$ git clone [email protected]:konifar/gradle-unused-resources-remover-plugin.git
$ cd gradle-unused-resources-remover-plugin

Edit build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

+//    classpath "gradle.plugin.com.github.konifar.gradle:plugin:0.3.3"
-    classpath "gradle.plugin.com.github.konifar.gradle:plugin:0.3.3"
    // For mavenLocal
+    classpath 'com.github.konifar.gradle:unused-resources-remover:0.3.3'
-//    classpath 'com.github.konifar.gradle:unused-resources-remover:0.3.3'
    }

Install to local maven

$ cd plugin
$ ./../gradlew assemble install

Run example

$ cd example
$ ./../gradlew removeUnusedResources
...
$ > Task :example:removeUnusedResources 
$ extraRemovers:
$   fileType: font, resourceName: string, type: DEFAULT
$   fileType: text_appearance, resourceName: style, type: STYLE
$ excludeNames:
$   fonts.xml
$ dryRun: false
$ [layout] ======== Start layout checking ========
$ [layout] example
$ [layout]   Remove unused_layout.xml
$ [layout]   Complete to remove files.
$ [layout] example-module
$ [layout]   No unused layout files.
$ [layout] plugin
...

Donation

If this plugin helps you, I would be so happy.

I'm welcome your tip by Kyash! My account name is konifar.

License

Copyright 2018 Yusuke Konishi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].