Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Refine the dependencies.constraints {} DSL #1091

Merged
merged 3 commits into from
Sep 13, 2018

Conversation

eskatos
Copy link
Member

@eskatos eskatos commented Sep 7, 2018

by generating accessors for known configurations

plugins { `java-library` }

dependencies {
    constraints {
        api("some:thing") {
            version { strictly("1.0") }
        }
    }
}

by adding classpath accessor for buildscript.dependencies.constraints {}

buildscript {
    dependencies {
        constraints {
            classpath("some:thing") {
                version { strictly("1.0") }
            }
        }
    }
}

by adding a configuration scope with string invoke operators

dependencies {
    (constraints) {
        "api"("some:thing") {
            version { strictly("1.0") }
        }
    }
}

Note that the configuration scope with support for the string invoke syntax can only be used by explicitly resolving the dependencies.constraints property (the extra parentheses above).

This happens because DependencyHandler.constraints(Action) would shadow a Kotlin extension providing the specialized configuration scope:

fun DependencyHandler.constraints(configuration: DependencyConstraintHandlerScope.() -> Unit) {
    // ...
}

by generating accessors for known configurations
by adding `classpath` accessor for buildscript.dependencies.constraints
by adding a configuration scope with string invoke operators

Signed-off-by: Paul Merlin <paul@gradle.com>
@eskatos eskatos added this to the 1.0-RC4 milestone Sep 7, 2018
@eskatos eskatos self-assigned this Sep 7, 2018
@eskatos eskatos requested a review from bamboo September 7, 2018 09:56
*
* @see [DependencyConstraintHandler]
*/
class DependencyConstraintHandlerScope(val constraints: DependencyConstraintHandler) : DependencyConstraintHandler by constraints {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be annotated with @Incubating the same way the underlying API is?

@eskatos eskatos modified the milestones: 1.0-RC4, 1.0-RC5 Sep 11, 2018
Signed-off-by: Paul Merlin <paul@gradle.com>
package org.gradle.kotlin.dsl.integration

import org.gradle.kotlin.dsl.fixtures.AbstractIntegrationTest
import org.gradle.kotlin.dsl.fixtures.containsMultiLineString
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Group imports

"direct-block:string-invoke",
"direct-block:string-invoke-with-action"
).forEach { dep ->
build("dependencyInsight", "--configuration", "compileClasspath", "--dependency", dep).apply {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Have you considered alternatives to avoid running that many builds?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependencyInsight report is the sole one giving the required information and it can only target one dependency at a time. Those builds will reuse the daemon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

Signed-off-by: Paul Merlin <paul@gradle.com>
@eskatos eskatos merged commit 10c480c into develop Sep 13, 2018
@eskatos eskatos deleted the eskatos/dependencies/constraints-dsl branch September 13, 2018 14:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants