me.tatarka.holdr.gradle.HoldrTask.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin Show documentation
Show all versions of gradle-plugin Show documentation
Generates view holders from Android layout files
package me.tatarka.holdr.gradle
import me.tatarka.holdr.compile.HoldrCompiler
import me.tatarka.holdr.compile.HoldrConfigImpl
import org.gradle.api.DefaultTask
import org.gradle.api.file.FileCollection
import org.gradle.api.logging.LogLevel
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
import org.gradle.api.tasks.incremental.InputFileDetails
public class HoldrTask extends DefaultTask {
@Input
String manifestPackage
@Input
String holdrPackage
@Input
boolean defaultInclude
@InputFiles
FileCollection resDirectories
@OutputDirectory
File outputDirectory
@TaskAction
void execute(IncrementalTaskInputs inputs) {
logging.captureStandardOutput(LogLevel.INFO)
def compiler = new HoldrCompiler(new HoldrConfigImpl(manifestPackage, holdrPackage, defaultInclude))
if (inputs.incremental) {
List changedFiles = []
List removedFiles = []
inputs.outOfDate { InputFileDetails changes ->
changedFiles += changes.file
}
inputs.removed { InputFileDetails change ->
removedFiles += change.file
}
compiler.compileIncremental(outputDirectory, resDirectories.files, changedFiles, removedFiles)
} else {
outputDirectory.deleteDir()
compiler.compile(outputDirectory, resDirectories.files)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy