com.jzbrooks.vgo.plugin.ShrinkVectorArtwork.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vgo-plugin Show documentation
Show all versions of vgo-plugin Show documentation
vgo is a gradle plugin for optimizing vector artwork files that helps ensure a compact representation without compromising quality.
The newest version!
package com.jzbrooks.vgo.plugin
import com.jzbrooks.vgo.Vgo
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.getByType
import java.io.File
open class ShrinkVectorArtwork : DefaultTask() {
private val extension = project.extensions.getByType()
private val defaultTree =
project.fileTree(project.projectDir) {
include("**/res/drawable*/*.xml")
}
init {
group = "resource"
description = "Shrink vector resources."
}
@get:Input
val files: List = (extension.inputs ?: defaultTree).files.map(File::getAbsolutePath)
@get:Input
val showStatistics = extension.showStatistics
@get:Input
val outputFormat = extension.format
@get:Input
val indent = extension.indent
@TaskAction
fun shrink() {
val options =
Vgo.Options(
printVersion = false,
printStats = showStatistics,
indent = indent.takeIf { it > 0 }?.toInt(),
output = emptyList(),
format = outputFormat.cliName,
input = files,
)
Vgo(options).run()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy