Task Failures with gradle LockMode.STRICT

Open
#2,906 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
kotlin
Domain
build-system

Research direction

Start with the root dependencyLocking configuration and the Spotless configuration shown in the report, then reproduce the failure with spotlessCheck and spotlessApply under LockMode.STRICT. Compare the strict and lenient configurations and verify that the ktlint version can be locked while both Spotless tasks complete successfully.

Written by the indexing model from the issue text.

Description

I enabled gradle dependency locking by following https://docs.gradle.org/current/userguide/dependency_locking.html

When setting the following in the root configuration:

dependencyLocking {
    lockAllConfigurations()
    lockMode = LockMode.STRICT
}

I get failures when running spotlessCheck and spotlessApply:

> Task :spotlessKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':spotlessKotlin'.
> You need to add a repository containing the '[com.pinterest.ktlint:ktlint-cli:1.8.0]' artifact in 'build.gradle'.
  E.g.: 'repositories { mavenCentral() }'

A workaround is to override the lockMode in the spotless configuration:

spotless {
    configurations.compileClasspath {
        dependencyLocking {
            lockMode = LockMode.LENIENT
        }
    }
}

But it would be nice if it were possible to lock the ktlint version and allow running with LockMode.STRICT all the way :)

Dominant language
Java
Stars
5.7k
Forks
560
Avg merge
1d 13h
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.