0

I've published a dependency locally. The dependency is located on path

C:\Users\myusername\.m2\repository\com\mycompany\my-library\1.0\*

which I think is the default path on Windows.

Now, on a different project I try to consume this library. My build.gradle looks like this(among other dependencies)

...
buildscript {
  repositories {
     mavenLocal()
  }
}
...
dependencies {
   implementation('com.mycompany:my-library:1.0')
}

I'm getting build errors that some classes do not exist etc...

Shouldn't this be enough to identify the dependency from local repository?

I also use a remote repository for other dependencies but the artifact name+version is unique(com.mycompany:my-library:1.0). I would expect to find this dependency from the local repository. Instead, I'm getting build errors that some classes do not exists etc...

EDIT:

The classes should be in the aforementioned library. I used ./gradlew publishToMavenLocal to publish the library locally, and I can see that it's there. Is is generated with the correct version etc..

nick
  • 1,611
  • 4
  • 20
  • 35
  • Are the classes in the jar? How did you publish it? – Thorbjørn Ravn Andersen Aug 30 '22 at 14:35
  • "Some classes don't exist" isn't particularly diagnostic; if the up-to-date artifact is published locally the normal Maven/Gradle resolution rules apply just fine. I would first (a) check your assumptions on what's been published and (b) check your assumptions for its transitive dependency config. – Dave Newton Aug 30 '22 at 14:35
  • I'm pretty sure that the library is published locally properly. I wouldn't rule out that it contains transitive dependencies. How can I ensure all dependencies are included? Even transitive – nick Aug 30 '22 at 15:21
  • By properly specifying dependencies in the published library. There's no way to diagnose further since we don't even know if the "missing classes" are supposed to be part of the published artifact or not, or if what's published is the most recent built artifact, etc. The version number is insufficient since that's often human-generated. – Dave Newton Aug 30 '22 at 15:29
  • The "missing classes" ARE supposed to be part of the published artifact. So, my guess it doesn't include transitive dependencies. I know it's the most recent built artifact since I can see the datetime. (Your questions are making me understand the problem better. Thank you) – nick Aug 30 '22 at 15:35

1 Answers1

0

The buildscript block configures the configuration of the gradle build itself. So by declaring the repositories in it, you are only affecting the buildscript. Try it outside of the buildscript

repositories {
     mavenLocal()
}


dependencies {
   implementation('com.mycompany:my-library:1.0')
}
user16358266
  • 397
  • 2
  • 7