androidgradlegradle-kotlin-dslkotlin-dsl

Use FlatDir in Gradle DependencyResolutionManagement


I wanted to use a local dependency (a jar file) relative to my root project directory in my main module as a buildscript classpath via dependencyResolutionManagement in settings.gradle.kts.

Here's my settings.gradle.kts file:

pluginManagement {
    repositories {
        google()
        mavenCentral()
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
      
        flatDir { dirs = setOf(File("plugins")) }
    }
}

rootProject.name = "AndroidApp"
include(":main", ":base")

However, gradle is resolving the path as C:\Users\Name\.gradle\daemon\7.5\plugins

I have tried below and none of them works:

1. File(".").absolutePath // C:\Users\Name\.gradle\daemon\7.5\.
2. rootProject.path // :
3. rootProject.children.size // 0

Solution

  • nevermind. I have made two mistakes:

    1. I need to declare in the pluginManagement block instead.
    2. Although it's resolving to gradle path initially, but it will use the correct relative path while resolving in the main module.