build: Deprecation fixes for Gradle 9.7.0
This commit is contained in:
@@ -10,4 +10,12 @@ gradlePlugin {
|
||||
id = "de.siphalor.tweed5.minecraft.mod.component"
|
||||
implementationClass = "de.siphalor.tweed5.gradle.plugin.minecraft.mod.MinecraftModComponentPlugin"
|
||||
}
|
||||
plugins.register("moduleInfo") {
|
||||
id = "de.siphalor.tweed5.module-info"
|
||||
implementationClass = "de.siphalor.tweed5.gradle.plugin.module_info.ModuleInfoPlugin"
|
||||
}
|
||||
plugins.register("rootProperties") {
|
||||
id = "de.siphalor.tweed5.root-properties"
|
||||
implementationClass = "de.siphalor.tweed5.gradle.plugin.root_properties.RootPropertiesPlugin"
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package de.siphalor.tweed5.gradle.plugin.module_info
|
||||
|
||||
import org.gradle.api.provider.Property
|
||||
|
||||
abstract class ModuleInfoExtension {
|
||||
abstract val name: Property<String>
|
||||
abstract val description: Property<String>
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package de.siphalor.tweed5.gradle.plugin.module_info
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
class ModuleInfoPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) {
|
||||
target.extensions.create("moduleInfo", ModuleInfoExtension::class.java)
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package de.siphalor.tweed5.gradle.plugin
|
||||
|
||||
import org.gradle.api.provider.MapProperty
|
||||
import org.gradle.api.provider.Provider
|
||||
|
||||
abstract class RootPropertiesExtension {
|
||||
abstract val properties: MapProperty<String, String>
|
||||
|
||||
operator fun get(key: String): Provider<String> = properties.getting(key)
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package de.siphalor.tweed5.gradle.plugin.root_properties
|
||||
|
||||
import de.siphalor.tweed5.gradle.plugin.RootPropertiesExtension
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.ProviderFactory
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import java.util.Properties
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class RootPropertiesPlugin : Plugin<Project> {
|
||||
@get:Inject
|
||||
abstract val providers: ProviderFactory
|
||||
|
||||
override fun apply(project: Project) {
|
||||
val rootPropertiesFile = if (project.layout.settingsDirectory.file(".gitmodules").asFile.exists()) {
|
||||
project.layout.settingsDirectory.file("gradle.properties")
|
||||
} else {
|
||||
project.layout.settingsDirectory.file("../gradle.properties")
|
||||
}
|
||||
|
||||
val rootProperties = providers.fileContents(rootPropertiesFile).asBytes.map { propsBytes ->
|
||||
Properties().apply {
|
||||
load(propsBytes.inputStream())
|
||||
}.map { it.key.toString() to it.value.toString() }.toMap()
|
||||
}
|
||||
|
||||
project.extensions.create("rootProperties", RootPropertiesExtension::class.java).apply {
|
||||
properties.value(rootProperties)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user