question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ktlintApplyToIdea fails on Cannot resolve external dependency

See original GitHub issue

Hi,

I am having issue with tasks ktlintApplyToIdea and ktlintApplyToIdeaGlobally in my project. Other tasks are running correctly and returns proper result but ktlintApplyToIdea returns:

Execution failed for task ':ktlintApplyToIdea'.
> Could not resolve all files for configuration ':ktlint'.
   > Cannot resolve external dependency com.github.shyiko:ktlint:0.29.0 because no repositories are defined.
     Required by:
         project :

My configuration of build.gradle.kts in root project:

buildscript {
    val kotlinVersion = "1.3.10"

    repositories {
        mavenCentral()
        gradlePluginPortal()
    }
   ....
}
plugins {
    val ktlintPluginVersion = "6.3.1"

    id("com.gradle.build-scan") version "2.0.2"
    id("org.jlleitschuh.gradle.ktlint") version ktlintPluginVersion
}
subprojects {
    apply(plugin = "kotlin")
    apply(plugin = "org.jlleitschuh.gradle.ktlint")
   ....
   tasks {
        configure<KtlintExtension> {
            debug.set(true)
            verbose.set(true)
            android.set(false)
            outputToConsole.set(true)
            reporters.addAll(ReporterType.PLAIN, ReporterType.CHECKSTYLE)
            ignoreFailures.set(true)
            filter {
                exclude("**/generated/**")
                include("**/kotlin/**")
            }
        }
  }
}

I am using Gradle 4.10.2 and Gradle 5 with both having same result. I tried adding ktlint dependency from error to buildscript.dependencies under classpath but I was unsucessful.

Do you know what is wrong? Thank you for answer.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pkubowiczcommented, Nov 25, 2019

@JLLeitschuh Your answer is wrong and this is a bug.

Gradle plugins should be isolated from compiling the code and their classpath is defined in buildscript{} block. Currently your plugin is polluting the code classpath.

Jakub’s project did not have any sources in the root project and there is no sense in defining any repositories for the root project.

1reaction
jakub-tucekcommented, Nov 30, 2018

My bad… I added repositories to:

allprojects {
   ...
    repositories {
        mavenCentral()
        gradlePluginPortal()
    }
}

and it works great now. Thank you for help & and this project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot resolve external dependency for gradle - Stack Overflow
The build fails and returns: Cannot resolve external dependency com.android.tools.build:gradle because no repositories are defined.
Read more >
MVNFE “Cannot resolve external dependency org.jetbrains ...
ModuleVersionNotFoundException : Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.41 because no repositories are defined.
Read more >
Cannot resolve external dependency com.android.tools.build ...
I do an update in my android studio, i have the following error. I know that the problem in build.gradle, how can i...
Read more >
Gradleのメモ
gradlew spotlessCheck Starting a Gradle Daemon (subsequent builds will be faster) FAILURE: Build failed with an exception. * What went wrong: Execution ...
Read more >
Getting errors when trying to run runClient - ForgeGradle
Error #1. Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Cannot resolve external dependency ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found