All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.astrainteractive.gradleplugin.processor.platform.FabricResourceProcessor.kt Maven / Gradle / Ivy

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)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy