Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use getter when determining whether custom config path is set in DetektGenerateConfigTask #5157

Merged
merged 1 commit into from Jul 31, 2022

Conversation

3flex
Copy link
Collaborator

@3flex 3flex commented Jul 31, 2022

Fixes #5097

Before this change, this task:

tasks.register("customDetektConfig", io.gitlab.arturbosch.detekt.DetektGenerateConfigTask::class) {
    config.setFrom("custom/location.yml")
    doLast {
        logger.warn("Configured path: ${config.asPath}")
    }
}

Would produce this output:

> Task :detekt-api:customDetektConfig
Skipping config file generation; file already exists at C:\<projectPath>\config\detekt\detekt.yml
Configured path: C:\<projectPath>\detekt-api\custom\location.yml

You can see the task was setting the config path and despite what was configured in the build file, the config wasn't being calculated correctly by the task.

With this PR, it will successfully generate the file:

> Task :detekt-api:customDetektConfig
Successfully copied default config to C:\<projectPath>\detekt-api\custom\location.yml
Configured path: C:\<projectPath>\detekt-api\custom\location.yml

And subsequent invocations will product the expected output:

> Task :detekt-api:customDetektConfig
Skipping config file generation; file already exists at C:\<projectPath>\detekt-api\custom\location.yml
Configured path: C:\<projectPath>\detekt-api\custom\location.yml

@cortinico cortinico added this to the 1.22.0 milestone Jul 31, 2022
@cortinico cortinico merged commit 9b5e12a into detekt:main Jul 31, 2022
19 checks passed
@3flex 3flex deleted the 5097-fix branch July 31, 2022 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DetektGenerateConfigTask does not respect custom config locations in 1.21.0
4 participants