Skip to content

Remove old deprecated APIs #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

- Target JVM 1.8 → 17
- Gradle 7.2 → 8.13
- Remove old deprecated APIs

## [0.10.1] - 2021-11-07

Expand Down
25 changes: 0 additions & 25 deletions src/main/kotlin/BukkitExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<ServerConfigurationImpl>) {
logger.warnSyntaxChanged("bukkit.run { ... }", "bukkit.server { ... }")
server(body)
}

public fun server(body: Action<ServerConfigurationImpl>) {
body.execute(server)
}
Expand All @@ -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",
Expand Down
12 changes: 0 additions & 12 deletions src/main/kotlin/extensions/Logger.kt

This file was deleted.

41 changes: 0 additions & 41 deletions src/main/kotlin/plugin/extension/PluginConfigurationImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> = objects.property<Boolean>()
Expand All @@ -25,44 +22,6 @@ public class PluginConfigurationImpl(objects: ObjectFactory) : PluginConfigurati
override val url: Property<String> = objects.property()
override val authors: ListProperty<String> = 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<String>) {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PrepareServerSpec extends PluginSpecification {
given: "configured online-mode"
buildFile << """
bukkit {
run {
server {
onlineMode = false
}
}
Expand Down