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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ val expandedSourcesElements = configurations.consumable("expandedSourcesElements
|
||||
|
||||
val delombok = tasks.getByName<Delombok>("delombok")
|
||||
|
||||
val sourcesJar by tasks.registering(Jar::class) {
|
||||
val sourcesJar = tasks.register<Jar>("sourcesJar") {
|
||||
group = LifecycleBasePlugin.BUILD_GROUP
|
||||
|
||||
dependsOn(delombok)
|
||||
|
||||
@@ -2,6 +2,8 @@ plugins {
|
||||
id("com.gradleup.shadow")
|
||||
java
|
||||
`java-library`
|
||||
id("de.siphalor.tweed5.root-properties")
|
||||
id("de.siphalor.tweed5.module-info")
|
||||
id("de.siphalor.tweed5.shadow.explicit")
|
||||
id("de.siphalor.tweed5.minecraft.mod.component")
|
||||
}
|
||||
@@ -24,9 +26,9 @@ fun formatJarsForJson(jars: FileCollection): String {
|
||||
tasks.register<Sync>("processMinecraftModResources") {
|
||||
inputs.property("id", project.name)
|
||||
inputs.property("version", project.version)
|
||||
inputs.property("name", properties["module.name"])
|
||||
inputs.property("description", properties["module.description"])
|
||||
inputs.property("repoUrl", properties["git.url"])
|
||||
inputs.property("name", moduleInfo.name)
|
||||
inputs.property("description", moduleInfo.description)
|
||||
inputs.property("repoUrl", rootProperties["git.url"])
|
||||
inputs.files(minecraftJijElements)
|
||||
|
||||
val jars = objects.fileCollection().apply { from(minecraftJijElements) }
|
||||
@@ -36,9 +38,9 @@ tasks.register<Sync>("processMinecraftModResources") {
|
||||
mapOf(
|
||||
"id" to project.name.replace('-', '_'),
|
||||
"version" to project.version,
|
||||
"name" to properties["module.name"],
|
||||
"description" to properties["module.description"],
|
||||
"repoUrl" to properties["git.url"],
|
||||
"name" to moduleInfo.name,
|
||||
"description" to moduleInfo.description,
|
||||
"repoUrl" to rootProperties["git.url"].get(),
|
||||
"jars" to formatJarsForJson(jars)
|
||||
)
|
||||
)
|
||||
@@ -52,9 +54,9 @@ tasks.register<Sync>("processMinecraftModResources") {
|
||||
tasks.register<Sync>("processMinecraftTestmodResources") {
|
||||
inputs.property("id", project.name)
|
||||
inputs.property("version", project.version)
|
||||
inputs.property("name", properties["module.name"])
|
||||
inputs.property("description", properties["module.description"])
|
||||
inputs.property("repoUrl", properties["git.url"])
|
||||
inputs.property("name", moduleInfo.name)
|
||||
inputs.property("description", moduleInfo.description)
|
||||
inputs.property("repoUrl", rootProperties["git.url"])
|
||||
inputs.files(minecraftJijElements)
|
||||
|
||||
val jars = objects.fileCollection().apply { from(minecraftJijElements) }
|
||||
@@ -64,9 +66,9 @@ tasks.register<Sync>("processMinecraftTestmodResources") {
|
||||
mapOf(
|
||||
"id" to "${project.name.replace('-', '_')}_testmod",
|
||||
"version" to project.version,
|
||||
"name" to "${properties["module.name"]} (test mod)",
|
||||
"description" to properties["module.description"],
|
||||
"repoUrl" to properties["git.url"],
|
||||
"name" to "${moduleInfo.name.get()} (test mod)",
|
||||
"description" to moduleInfo.description,
|
||||
"repoUrl" to rootProperties["git.url"].get(),
|
||||
"jars" to formatJarsForJson(jars)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2,8 +2,8 @@ import org.gradle.api.publish.internal.PublicationInternal
|
||||
|
||||
plugins {
|
||||
`maven-publish`
|
||||
id("de.siphalor.tweed5.publishing")
|
||||
id("de.siphalor.tweed5.minecraft.mod.base")
|
||||
id("de.siphalor.tweed5.publishing")
|
||||
}
|
||||
|
||||
val minecraftModJar = tasks.register<Jar>("minecraftModJar") {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("de.siphalor.tweed5.root-properties")
|
||||
id("de.siphalor.tweed5.module-info")
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
@@ -23,11 +25,11 @@ publishing {
|
||||
publications.all {
|
||||
if (this is MavenPublication) {
|
||||
pom {
|
||||
name = project.property("module.name") as String
|
||||
description = project.property("module.description") as String
|
||||
url = project.property("git.url") as String
|
||||
name = moduleInfo.name
|
||||
description = moduleInfo.description
|
||||
url = rootProperties["git.url"]
|
||||
scm {
|
||||
url = project.property("git.url") as String
|
||||
url = rootProperties["git.url"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import java.util.Properties
|
||||
|
||||
val rootPropertiesFile = project.layout.settingsDirectory.file("../gradle.properties").asFile
|
||||
if (rootPropertiesFile.exists()) {
|
||||
Properties()
|
||||
.apply { rootPropertiesFile.inputStream().use { load(it) } }
|
||||
.forEach { (key, value) -> project.ext.set(key.toString(), value.toString()) }
|
||||
}
|
||||
Reference in New Issue
Block a user