Skip to content

problems loading ktlint/ktfmt when using buildsrc #740

Closed

Description

@xenoterracide
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Cannot resolve external dependency com.facebook:ktfmt:0.16 because no repositories are defined.
Required by:
    project :
You probably need to add a repository containing the '[com.facebook:ktfmt:0.16]' artifact in the 'build.gradle' of your root project.
E.g.: 'buildscript { repositories { mavenCentral() }}'

tried this in my buildSrc/build.gradle.kts

repositories {
  gradlePluginPortal()
  mavenCentral()// so that external plugins can be resolved in dependencies section
}

dependencies {
  implementation("com.facebook:ktfmt:0.16")

and the suggested buildscript

> Failed to apply plugin 'ppm.java-convention'.
   > The `buildscript` block is not supported on Kotlin script plugins, please use the `plugins` block or project level dependencies.

https://github.com/tbroyer/gradle-errorprone-plugin creates its own scope for error prone to add it, maybe this is the right way to do it?

Activity

  1. nedtwigg commented on Nov 18, 2020

    @nedtwigg
    Member

    It will need to be in /build.gradle.kts, not in buildSrc/build.gradle.kts.

    If you can't add it there, the other place you can add it is in settings.gradle:

    pluginManagement {
      repositories {
        mavenCentral()
        gradlePluginPortal()
      }
    

    I know that settings.gradle pluginManagement { repositories { thing is a relatively new thing. Dunno when/if the old buildscript { repositories { thing was removed.

    Would be great for this error message to be gradle-version-dependent, PR's wanted.

  2. nedtwigg commented on Jan 4, 2021

    @nedtwigg
    Member

    Closing due to inactivity, happy to discuss further if new info arises.

  3. wsdydeni commented on Nov 5, 2021

    @wsdydeni

    It will need to be in /build.gradle.kts, not in buildSrc/build.gradle.kts.

    If you can't add it there, the other place you can add it is in settings.gradle:

    pluginManagement {
      repositories {
        mavenCentral()
        gradlePluginPortal()
      }
    

    I know that settings.gradle pluginManagement { repositories { thing is a relatively new thing. Dunno when/if the old buildscript { repositories { thing was removed.

    Would be great for this error message to be gradle-version-dependent, PR's wanted.

    so thinks,this code successfully solved my problem,but my problem is

    The buildscript block is not supported on Kotlin script plugins, please use the plugins block or project level dependencies.

    my environment is gradle 6.7.1 kotlin 1.5.31 gradle plugin 4.2.2

  4. nedtwigg commented on Nov 5, 2021

    @nedtwigg
    Member

    I would watch #941 for a resolution to this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions