From a4669ff5bd9417d9214dd012e6f558a6597701cd Mon Sep 17 00:00:00 2001 From: Osip Fatkullin Date: Mon, 14 Apr 2025 00:38:14 +0200 Subject: [PATCH 1/2] chore: Use Kotlin DSL in test build scripts --- .../bukkitgradle/PluginSpecification.groovy | 14 ++++---- .../plugin/task/MergePluginYamlSpec.groovy | 36 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/test/groovy/ru/endlesscode/bukkitgradle/PluginSpecification.groovy b/src/test/groovy/ru/endlesscode/bukkitgradle/PluginSpecification.groovy index 69cb306..17a5a15 100644 --- a/src/test/groovy/ru/endlesscode/bukkitgradle/PluginSpecification.groovy +++ b/src/test/groovy/ru/endlesscode/bukkitgradle/PluginSpecification.groovy @@ -22,21 +22,21 @@ class PluginSpecification extends Specification { protected BuildResult result def setup() { - buildFile = file('build.gradle') - settingsFile = file('settings.gradle') + buildFile = file('build.gradle.kts') + settingsFile = file('settings.gradle.kts') - //language=gradle + //language=kotlin buildFile << ''' plugins { - id 'ru.endlesscode.bukkitgradle' + id("ru.endlesscode.bukkitgradle") } - version = '1.0' - group = 'com.example.testplugin' + version = "1.0" + group = "com.example.testplugin" '''.stripIndent() settingsFile << ''' - rootProject.name = 'test-plugin' + rootProject.name = "test-plugin" '''.stripIndent() } diff --git a/src/test/groovy/ru/endlesscode/bukkitgradle/plugin/task/MergePluginYamlSpec.groovy b/src/test/groovy/ru/endlesscode/bukkitgradle/plugin/task/MergePluginYamlSpec.groovy index 977d4ce..c674467 100644 --- a/src/test/groovy/ru/endlesscode/bukkitgradle/plugin/task/MergePluginYamlSpec.groovy +++ b/src/test/groovy/ru/endlesscode/bukkitgradle/plugin/task/MergePluginYamlSpec.groovy @@ -121,17 +121,17 @@ class MergePluginYamlSpec extends PluginSpecification { void 'when merge plugin.yaml - and all properties configured - should write all lines'() { given: "configured all plugin properties" - //language=gradle + //language=kotlin buildFile << """ bukkit { plugin { - name.set('TestPlugin') - description.set('Test plugin description') - main.set('com.example.plugin.Plugin') - version.set('0.1') - apiVersion.set('1.13') - url.set('http://www.example.com/') - authors.set(["OsipXD", "Contributors"]) + name.set("TestPlugin") + description.set("Test plugin description") + main.set("com.example.plugin.Plugin") + version.set("0.1") + apiVersion.set("1.13") + url.set("https://www.example.com/") + authors.set(listOf("OsipXD", "Contributors")) } } """.stripIndent() @@ -147,22 +147,22 @@ class MergePluginYamlSpec extends PluginSpecification { version: "0.1" api-version: "1.13" authors: ["OsipXD", "Contributors"] - website: "http://www.example.com/" + website: "https://www.example.com/" """.stripIndent().trim() } - void 'when merge plugin.yaml - and all properties configured old way - should write all lines'() { + void 'when merge plugin.yaml - and all properties configured with assignment - should write all lines'() { given: "configured all plugin properties in old way" - //language=gradle + //language=kotlin buildFile << """ bukkit { plugin { - name = 'TestPlugin' - description = 'Test plugin description' - main = 'com.example.plugin.Plugin' - version = '0.1' - url = 'http://www.example.com/' - authors = ["OsipXD", "Contributors"] + name = "TestPlugin" + description = "Test plugin description" + main = "com.example.plugin.Plugin" + version = "0.1" + url = "https://www.example.com/" + authors = listOf("OsipXD", "Contributors") } } """.stripIndent() @@ -178,7 +178,7 @@ class MergePluginYamlSpec extends PluginSpecification { version: "0.1" api-version: "1.16" authors: ["OsipXD", "Contributors"] - website: "http://www.example.com/" + website: "https://www.example.com/" """.stripIndent().trim() } From f45fbd3061bf96716c9fbbf4c506d4562d1c4348 Mon Sep 17 00:00:00 2001 From: Osip Fatkullin Date: Mon, 14 Apr 2025 00:38:38 +0200 Subject: [PATCH 2/2] chore: Remove deprecated APIs --- CHANGELOG.md | 1 + src/main/kotlin/BukkitExtension.kt | 25 ----------- src/main/kotlin/extensions/Logger.kt | 12 ------ .../extension/PluginConfigurationImpl.kt | 41 ------------------- .../server/task/PrepareServerSpec.groovy | 2 +- 5 files changed, 2 insertions(+), 79 deletions(-) delete mode 100644 src/main/kotlin/extensions/Logger.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 0977ded..e2df779 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - Target JVM 1.8 → 17 - Gradle 7.2 → 8.13 +- Remove old deprecated APIs ## [0.10.1] - 2021-11-07 diff --git a/src/main/kotlin/BukkitExtension.kt b/src/main/kotlin/BukkitExtension.kt index 6ab59ea..fb33d3f 100644 --- a/src/main/kotlin/BukkitExtension.kt +++ b/src/main/kotlin/BukkitExtension.kt @@ -4,17 +4,13 @@ import org.gradle.api.Action import org.gradle.api.Project import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property -import org.gradle.kotlin.dsl.assign import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.property -import org.slf4j.LoggerFactory import ru.endlesscode.bukkitgradle.extensions.finalizedOnRead -import ru.endlesscode.bukkitgradle.extensions.warnSyntaxChanged import ru.endlesscode.bukkitgradle.plugin.extension.PluginConfigurationImpl import ru.endlesscode.bukkitgradle.server.ServerConstants import ru.endlesscode.bukkitgradle.server.extension.ServerConfigurationImpl -// TODO 1.0: Remove deprecated fields on release public open class BukkitExtension internal constructor( public final override val plugin: PluginConfigurationImpl, public final override val server: ServerConfigurationImpl, @@ -25,21 +21,6 @@ public open class BukkitExtension internal constructor( .convention(ServerConstants.DEFAULT_VERSION) .finalizedOnRead() - private val logger = LoggerFactory.getLogger("BukkitExtension") - - @Deprecated("Use 'server' instead", ReplaceWith("server")) - public val run: ServerConfigurationImpl - get() { - logger.warnSyntaxChanged("bukkit.run", "bukkit.server") - return server - } - - @Deprecated("Use 'server { ... }' instead", ReplaceWith("server(body)")) - public fun run(body: Action) { - logger.warnSyntaxChanged("bukkit.run { ... }", "bukkit.server { ... }") - server(body) - } - public fun server(body: Action) { body.execute(server) } @@ -53,12 +34,6 @@ public open class BukkitExtension internal constructor( plugin(body) } - @Deprecated("Use apiVersion instead of version.", ReplaceWith("apiVersion = version")) - public fun setVersion(version: String) { - logger.warnSyntaxChanged("bukkit.version = '...'", "bukkit.apiVersion = '...'") - apiVersion = version - } - /** Disables plugin.yml generation. */ @Deprecated( "Use 'plugin.disablePluginYamlGeneration()' instead", diff --git a/src/main/kotlin/extensions/Logger.kt b/src/main/kotlin/extensions/Logger.kt deleted file mode 100644 index 741e29c..0000000 --- a/src/main/kotlin/extensions/Logger.kt +++ /dev/null @@ -1,12 +0,0 @@ -package ru.endlesscode.bukkitgradle.extensions - -import org.slf4j.Logger - -internal fun Logger.warnSyntaxChanged(oldSyntax: String, newSyntax: String) { - warn( - """ - Syntax $oldSyntax is deprecated and will be removed in 1.0 - Replace it with: $newSyntax - """.trimIndent() - ) -} diff --git a/src/main/kotlin/plugin/extension/PluginConfigurationImpl.kt b/src/main/kotlin/plugin/extension/PluginConfigurationImpl.kt index 2625cbf..3b400d6 100644 --- a/src/main/kotlin/plugin/extension/PluginConfigurationImpl.kt +++ b/src/main/kotlin/plugin/extension/PluginConfigurationImpl.kt @@ -5,11 +5,8 @@ import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import org.gradle.kotlin.dsl.listProperty import org.gradle.kotlin.dsl.property -import org.slf4j.LoggerFactory import ru.endlesscode.bukkitgradle.extensions.finalizedOnRead -import ru.endlesscode.bukkitgradle.extensions.warnSyntaxChanged -// TODO 1.0: Remove deprecated methods public class PluginConfigurationImpl(objects: ObjectFactory) : PluginConfiguration { private val _generatePluginYaml: Property = objects.property() @@ -25,44 +22,6 @@ public class PluginConfigurationImpl(objects: ObjectFactory) : PluginConfigurati override val url: Property = objects.property() override val authors: ListProperty = objects.listProperty() - private val logger = LoggerFactory.getLogger("PluginConfiguration") - - @Deprecated("Use property syntax instead", ReplaceWith("this.name.set(name)")) - public fun setName(name: String) { - logger.warnSyntaxChanged("bukkit.plugin.name = '...'", "bukkit.plugin.name.set('...')") - this.name.set(name) - } - - @Deprecated("Use property syntax instead", ReplaceWith("this.description.set(description)")) - public fun setDescription(description: String) { - logger.warnSyntaxChanged("bukkit.plugin.description = '...'", "bukkit.plugin.description.set('...')") - this.description.set(description) - } - - @Deprecated("Use property syntax instead", ReplaceWith("this.main.set(main)")) - public fun setMain(main: String) { - logger.warnSyntaxChanged("bukkit.plugin.main = '...'", "bukkit.plugin.main.set('...')") - this.main.set(main) - } - - @Deprecated("Use property syntax instead", ReplaceWith("this.version.set(version)")) - public fun setVersion(version: String) { - logger.warnSyntaxChanged("bukkit.plugin.version = '...'", "bukkit.plugin.version.set('...')") - this.version.set(version) - } - - @Deprecated("Use property syntax instead", ReplaceWith("this.url.set(url)")) - public fun setUrl(url: String) { - logger.warnSyntaxChanged("bukkit.plugin.url = '...'", "bukkit.plugin.url.set('...')") - this.url.set(url) - } - - @Deprecated("Use property syntax instead", ReplaceWith("this.authors.set(authors)")) - public fun setAuthors(authors: List) { - logger.warnSyntaxChanged("bukkit.plugin.authors = [...]", "bukkit.plugin.authors.set([...])") - this.authors.set(authors) - } - /** Disables plugin.yaml parsing and generation. */ public fun disablePluginYamlGeneration() { _generatePluginYaml.set(false) diff --git a/src/test/groovy/ru/endlesscode/bukkitgradle/server/task/PrepareServerSpec.groovy b/src/test/groovy/ru/endlesscode/bukkitgradle/server/task/PrepareServerSpec.groovy index 98a0433..abf4b23 100644 --- a/src/test/groovy/ru/endlesscode/bukkitgradle/server/task/PrepareServerSpec.groovy +++ b/src/test/groovy/ru/endlesscode/bukkitgradle/server/task/PrepareServerSpec.groovy @@ -33,7 +33,7 @@ class PrepareServerSpec extends PluginSpecification { given: "configured online-mode" buildFile << """ bukkit { - run { + server { onlineMode = false } }