-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DependencyConstraintFactories as they are used in multiple DSLs
- Loading branch information
Showing
6 changed files
with
61 additions
and
92 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/DependencyConstraintFactories.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.sgtsilvio.gradle.oci.dsl | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.DependencyConstraint | ||
import org.gradle.api.artifacts.MinimalExternalModuleDependency | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.provider.ProviderConvertible | ||
|
||
/** | ||
* @author Silvio Giebl | ||
*/ | ||
interface DependencyConstraintFactories { | ||
|
||
fun constraint(dependencyConstraintNotation: CharSequence): DependencyConstraint | ||
|
||
fun constraint(project: Project): DependencyConstraint | ||
|
||
fun constraint(dependencyProvider: Provider<out MinimalExternalModuleDependency>): Provider<DependencyConstraint> | ||
|
||
fun constraint(dependencyProvider: ProviderConvertible<out MinimalExternalModuleDependency>) = | ||
constraint(dependencyProvider.asProvider()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...n/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/DependencyConstraintFactoriesImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.github.sgtsilvio.gradle.oci.internal.dsl | ||
|
||
import io.github.sgtsilvio.gradle.oci.dsl.DependencyConstraintFactories | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.DependencyConstraint | ||
import org.gradle.api.artifacts.MinimalExternalModuleDependency | ||
import org.gradle.api.artifacts.dsl.DependencyConstraintHandler | ||
import org.gradle.api.provider.Provider | ||
|
||
/** | ||
* @author Silvio Giebl | ||
*/ | ||
abstract class DependencyConstraintFactoriesImpl( | ||
private val dependencyConstraintHandler: DependencyConstraintHandler, | ||
) : DependencyConstraintFactories { | ||
|
||
final override fun constraint(dependencyConstraintNotation: CharSequence): DependencyConstraint = | ||
dependencyConstraintHandler.create(dependencyConstraintNotation) | ||
|
||
final override fun constraint(project: Project): DependencyConstraint = dependencyConstraintHandler.create(project) | ||
|
||
private fun constraint(dependency: MinimalExternalModuleDependency): DependencyConstraint = | ||
dependencyConstraintHandler.create(dependency) | ||
|
||
final override fun constraint( | ||
dependencyProvider: Provider<out MinimalExternalModuleDependency>, | ||
): Provider<DependencyConstraint> = dependencyProvider.map { constraint(it) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters