Skip to content
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

Rename apply to register for GradmIntegrationsExtension #52

Merged
merged 1 commit into from
Apr 21, 2023
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
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ In `gradm/build.gradle.kts`:
```kotlin
gradm {
integrations {
apply("github") {
register("github") {
// We can temporarily disable the integration, without delete the whole configuration.
enabled = true // default: true
configFilePath = "gradm.integration.github.yml" // default: "gradm.integration.github.yml"
Expand Down
2 changes: 1 addition & 1 deletion docs/zh-Hans/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ gradm {
```kotlin
gradm {
integrations {
apply("github") {
register("github") {
// 我们可以暂时禁用集成,而不删除整个配置。
enabled = true // 默认为 true
configFilePath = "gradm.integration.github.yml" // 默认为 "gradm.integration.github.yml"
Expand Down
2 changes: 1 addition & 1 deletion examples/gradm-getting-started/gradm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gradm {
indent = 2 // default: 2
}
integrations {
apply("github") {
register("github") {
enabled = true // default: true
configFilePath = "gradm.integration.github.yml" // default: "gradm.integration.github.yml"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ package me.omico.gradm.integration
import org.gradle.api.Action
import org.gradle.api.plugins.ExtensionAware

// TODO Remove deprecated methods in Gradm 5.0.0.
interface GradmIntegrationsExtension : ExtensionAware {
@Deprecated(
message = "Use `apply` instead. This method will be removed in Gradm 5.0.0.",
replaceWith = ReplaceWith("apply(id)"),
level = DeprecationLevel.WARNING,
)
fun apply(id: String)

@Deprecated(
message = "Use `apply` instead. This method will be removed in Gradm 5.0.0.",
replaceWith = ReplaceWith("apply(id, configure)"),
level = DeprecationLevel.WARNING,
)
fun apply(id: String, configure: Action<GradmIntegrationExtension>)

fun register(id: String)
fun register(id: String, configure: Action<GradmIntegrationExtension>)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ import me.omico.gradm.integration.GradmIntegrationsExtension
import org.gradle.api.Action

internal abstract class GradmIntegrationsExtensionImpl : GradmIntegrationsExtension {
override fun apply(id: String) = apply(id) {}
override fun apply(id: String, configure: Action<GradmIntegrationExtension>) =
@Suppress("OVERRIDE_DEPRECATION")
override fun apply(id: String) = register(id)

@Suppress("OVERRIDE_DEPRECATION")
override fun apply(id: String, configure: Action<GradmIntegrationExtension>) = register(id, configure)

override fun register(id: String) = register(id) {}
override fun register(id: String, configure: Action<GradmIntegrationExtension>) =
GradmIntegrationExtensionImpl(id)
.apply(configure::execute)
.toConfiguration()
Expand Down