Skip to content

Commit

Permalink
Refactor OciImageDependencies: default methods for ProviderConvertible
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Feb 26, 2024
1 parent 73ff7fc commit 703fbb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ interface OciImageDependencies<T> {

fun add(project: Project, action: Action<in ProjectDependency>): T

fun add(dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>): T
fun add(dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>) =
add(dependencyProvider.asProvider())

fun add(
dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>,
action: Action<in ExternalModuleDependency>,
): T
) = add(dependencyProvider.asProvider(), action)

// add constraint

Expand All @@ -67,7 +68,8 @@ interface OciImageDependencies<T> {

fun constraint(dependencyProvider: Provider<out MinimalExternalModuleDependency>): Provider<DependencyConstraint>

fun constraint(dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>): Provider<DependencyConstraint>
fun constraint(dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>) =
constraint(dependencyProvider.asProvider())

// dsl syntactic sugar for adding dependency

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.*
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderConvertible
import org.gradle.kotlin.dsl.withType

/**
Expand Down Expand Up @@ -74,14 +73,6 @@ internal abstract class OciImageDependenciesImpl<T>(
final override fun add(project: Project, action: Action<in ProjectDependency>) =
add(createDependency(project), action)

final override fun add(dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>) =
add(dependencyProvider.asProvider())

final override fun add(
dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>,
action: Action<in ExternalModuleDependency>,
) = add(dependencyProvider.asProvider(), action)

// add constraint

final override fun add(dependencyConstraint: DependencyConstraint) {
Expand Down Expand Up @@ -118,7 +109,4 @@ internal abstract class OciImageDependenciesImpl<T>(

final override fun constraint(dependencyProvider: Provider<out MinimalExternalModuleDependency>) =
dependencyProvider.map { constraint(it) }

final override fun constraint(dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>) =
constraint(dependencyProvider.asProvider())
}

0 comments on commit 703fbb5

Please sign in to comment.