From 8318ac29e81b6a77ed9ec223b2024cb7a61c7175 Mon Sep 17 00:00:00 2001 From: FinlayRJW <88376465+FinlayRJW@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:38:56 +0000 Subject: [PATCH] Add `checkOverbroadConstraints` to `check` task (#1258) Add `checkOverbroadConstraints` to `check` task --- changelog/@unreleased/pr-1258.v2.yml | 5 +++++ .../gradle/versions/VersionsPropsPlugin.java | 18 ++++++++---------- ...kOverbroadConstraintsIntegrationSpec.groovy | 11 +++++------ 3 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 changelog/@unreleased/pr-1258.v2.yml diff --git a/changelog/@unreleased/pr-1258.v2.yml b/changelog/@unreleased/pr-1258.v2.yml new file mode 100644 index 00000000..a61bea09 --- /dev/null +++ b/changelog/@unreleased/pr-1258.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Add `checkOverbroadConstraints` to `check` task + links: + - https://github.com/palantir/gradle-consistent-versions/pull/1258 diff --git a/src/main/java/com/palantir/gradle/versions/VersionsPropsPlugin.java b/src/main/java/com/palantir/gradle/versions/VersionsPropsPlugin.java index b11708aa..b1109100 100644 --- a/src/main/java/com/palantir/gradle/versions/VersionsPropsPlugin.java +++ b/src/main/java/com/palantir/gradle/versions/VersionsPropsPlugin.java @@ -92,16 +92,14 @@ public final void apply(Project project) { }); project.getTasks().named("check").configure(task -> task.dependsOn(checkNoUnusedConstraints)); - // Currently checkOverbroadConstraints is not running as part of check while for testing - uncomment once - // testing is complete (also uncomment groovy test) - // TaskProvider checkOverbroadConstraints = - project.getTasks().register("checkOverbroadConstraints", CheckOverbroadConstraints.class, task -> { - task.getLockFile().set(project.getLayout().getProjectDirectory().file("versions.lock")); - task.getPropsFile() - .set(project.getLayout().getProjectDirectory().file("versions.props")); - }); - // project.getTasks().named("check").configure(task -> - // task.dependsOn(checkOverbroadConstraints)); + TaskProvider checkOverbroadConstraints = project.getTasks() + .register("checkOverbroadConstraints", CheckOverbroadConstraints.class, task -> { + task.getLockFile() + .set(project.getLayout().getProjectDirectory().file("versions.lock")); + task.getPropsFile() + .set(project.getLayout().getProjectDirectory().file("versions.props")); + }); + project.getTasks().named("check").configure(task -> task.dependsOn(checkOverbroadConstraints)); // Create "platform" configuration in root project, which will hold the versions props constraints project.getConfigurations().register(GCV_VERSIONS_PROPS_CONSTRAINTS_CONFIGURATION_NAME, conf -> { diff --git a/src/test/groovy/com/palantir/gradle/versions/CheckOverbroadConstraintsIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/versions/CheckOverbroadConstraintsIntegrationSpec.groovy index 6cbbd2ab..6cda7702 100644 --- a/src/test/groovy/com/palantir/gradle/versions/CheckOverbroadConstraintsIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/versions/CheckOverbroadConstraintsIntegrationSpec.groovy @@ -53,12 +53,11 @@ class CheckOverbroadConstraintsIntegrationSpec extends IntegrationSpec { runTasks('checkOverbroadConstraints') } -// Currently checkOverbroadConstraints is not running as part of check while for testing uncomment once re-added to check -// def 'Task should run as part of :check'() { -// expect: -// def result = runTasks('check', '-m') -// result.output.contains(':checkOverbroadConstraints') -// } + def 'Task should run as part of :check'() { + expect: + def result = runTasks('check', '-m') + result.output.contains(':checkOverbroadConstraints') + } def 'All versions are pinned'() { when: