ru.astrainteractive.gradleplugin.processor.platform.FabricResourceProcessor.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minecraft Show documentation
Show all versions of minecraft Show documentation
GradlePlugin for my kotlin projects
The newest version!
package ru.astrainteractive.gradleplugin.processor.platform
import org.gradle.api.Project
import org.gradle.kotlin.dsl.named
import org.gradle.language.jvm.tasks.ProcessResources
import ru.astrainteractive.gradleplugin.processor.core.ResourceProcessor
import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.requireProjectInfo
class FabricResourceProcessor(private val project: Project) : ResourceProcessor {
data class Info(
val version: String,
) : ResourceProcessor.ProcessorInfo
override fun getProcessorInfo(): Info {
val projectInfo = project.requireProjectInfo
return Info(
version = projectInfo.versionString,
)
}
override fun getDefaultProperties(): Map {
val processorInfo = getProcessorInfo()
return mapOf(
"version" to processorInfo.version
)
}
override fun process(configuration: ProcessResources.() -> Unit) {
val processorInfo = getProcessorInfo()
project.tasks.named("processResources") {
filteringCharset = "UTF-8"
inputs.property("version", processorInfo.version)
filesMatching("fabric.mod.json") {
expand(getDefaultProperties())
}
configuration.invoke(this)
}
}
}