Search code examples
javamavengradlebuild.gradlegradlew

How do I reload all the dependencies from mavenLocal using gradle?


I have Project A and B in my system and B uses some of the packages defined in A and I have added some classes in project A but i am not able to reference them in B.

What I have tried

  1. Did ./gradlew publishToMavenLocal in project A
  2. Did ./gradlew build --refresh-dependencies

Can some please advise me how can I achieve this ?

Thanks


Solution

  • Assuming you did step 2 in project B, it should work (although I would like do a clean as well): ./gradlew clean build --refresh-dependencies

    If you do this a lot (and esp if you find it tedious to type --refresh-dependencies every time, you could consider marking the dependency from project A as changing...

    configurations.all { resolutionStrategy.cacheChangingModulesFor 0, "seconds" }
    dependencies {
        implementation("com.example.group:my-artifact:3.2.1")) { changing = true }
    // ...
    }
    

    The configurations block tells Gradle how to handle changing modules, and the the changing = true will flag individual dependencies. Then, every Gradle build, it will try to update the dependency.