Skip to content

Commit

Permalink
Workaround to "remove" the last usage of ConfigureUtil.
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob committed Feb 16, 2023
1 parent 2c02103 commit 6df29b3
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import groovy.lang.Closure
import org.gradle.api.Action
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.internal.NamedDomainObjectContainerConfigureDelegate
import org.gradle.util.GradleVersion
import java.net.URI
import javax.inject.Inject

Expand All @@ -36,10 +37,28 @@ internal open class DefaultNexusRepositoryContainer @Inject constructor(
}

override fun configure(configureClosure: Closure<*>): NamedDomainObjectContainer<NexusRepository> =
@Suppress("DEPRECATION") // TODO https://github.com/gradle-nexus/publish-plugin/issues/152
org.gradle.util.ConfigureUtil.configureSelf(
configureClosure,
this,
NamedDomainObjectContainerConfigureDelegate(configureClosure, this)
)
if (GradleVersion.current() <= GradleVersion.version("7.6")) {
@Suppress("DEPRECATION")
// Keep using the old API on old Gradle versions.
// It was deprecated in Gradle 7.1, but only from Gradle 7.6 it emits a deprecation warning.
// https://docs.gradle.org/current/userguide/upgrading_version_7.html#org_gradle_util_reports_deprecations
// Note: this will fail to compile when this project starts building on Gradle 9.0,
// at which point, this will need to be fully resolved,
// OR this call for older support will need to be removed OR reflective.
org.gradle.util.ConfigureUtil.configureSelf(
configureClosure,
this,
NamedDomainObjectContainerConfigureDelegate(configureClosure, this)
)
} else {
// Keep using the new *internal* API on new Gradle versions.
// At least until https://github.com/gradle/gradle/issues/23874 is resolved.
// Introduced in Gradle 7.1, it's internal but stable up until the latest Gradle 8.0 at the time of writing.
// The Gradle 7.1 version of this class is a verbatim copy of Gradle 8.0's version, but without the nagging.
org.gradle.util.internal.ConfigureUtil.configureSelf(
configureClosure,
this,
NamedDomainObjectContainerConfigureDelegate(configureClosure, this)
)
}
}

0 comments on commit 6df29b3

Please sign in to comment.