在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):konifar/gradle-unused-resources-remover-plugin开源软件地址(OpenSource Url):https://github.com/konifar/gradle-unused-resources-remover-plugin开源编程语言(OpenSource Language):Groovy 83.9%开源软件介绍(OpenSource Introduction):Unused Resources Remover for AndroidGradle Plugin that removes unused resources in Android projects. Features
Simple usagebuild.gradlebuildscript {
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.gradleapply plugin: "com.github.konifar.gradle.unused-resources-remover" Run$ ./gradlew removeUnusedResources Hook to Clean Project(Optional)If you want to hook to app/build.gradleclean.dependsOn(removeUnusedResources) Advanced usageThis 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 Here is two example.
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 ContributingThis project is under development. I'm always welcome your contribution! Feel free to report Issue or send Pull Request! Project structure
Download repository$ git clone [email protected]:konifar/gradle-unused-resources-remover-plugin.git
$ cd gradle-unused-resources-remover-plugin Edit build.gradledependencies {
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
... DonationIf this plugin helps you, I would be so happy. I'm welcome your tip by Kyash! My account name is License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论