hey! im trying to publish locally an artifact/libr...
# community-support
n
hey! im trying to publish locally an artifact/library and consume from another project. the artifact, with the correct version is indeed created in the .m2 folder. but, its not added to gradle cache, instead it takes some version from upstream the code is using the right class in compilation, but in runtime(running with intellij) the classpath is gradle cache, and its not there
v
did you add the
mavenLocal
repository in your repositories definition ? Otherwise Gradle fetches dependencies from the repositories you defined
n
Umm I'm starting to thibk there's a transative decency in this module on a fixed version
Dependency
v
this also may be the issue indeed
v
You should strongly consider not using Maven Local either way, it is broken by design in Maven already. It makes your builds slow and unreliable at best, silently behaving wrongly at worst. Whenever you can you should avoid using it and instead use a composite build to test one Gradle built library in another Gradle build as long as the Gradle versions are compatible (optimally the same). If not, then it is preferable to deploy to some dedicated local directory-based repository other than
mavenLocal()
. And if you really need to use
mavenLocal()
it should always be last in the list of repositories, and optimally always with a repository content filter that controls what exactly is taken from there. That the artifacts taken from Maven Local are not added to the Gradle Cache is normal. One of the greatest strengths of Gradle is to avoid unnecessary work, and copying around the local file from Maven Local to the Gradle Cache would be such unnecessary work, so if done properly, it is directly used from that repository.
n
umm not sure i fully understand. i want to use maven local to be able to work locally with the updated artifact. its not something we do in our ci/cd
in the end it was a transitive depedency of the same module with a fixed version btw 🙂
v
Yes, and exactly for this use-case (and others but originally for this use-case) Gradle has a much better alternative 🙂
n
oh
its called "gradle composite"?
v
If you use a composite build (as long as the Gradle versions are compatible), you include the build of the library in your main build, then any version that is declared for the library is ignored and Gradle automatically builds the library whenever necessary and uses the build result.
And if you open the main project in your ide, also the included build gets opened alongside automatically
So you can pretty comfortable work on the changes on both sides and try them out right away without the tedious "edit library, publish library to mc, edit app, try app" cycle.
n
ill read about. thanks a lot for your tip!
👌 1