"gradle install" doesn't work. What am I doing wrong?

I’m trying to build a java library (jar + pom) that I want to distribute. I’m running “gradle build” and that looks nice, no significant errors, but also no artefacts added to my “~/.m2/repository”. My colleague checked out the same repo, ran the same command, and it did produce jar+pom in the appropriate location in .m2.

So

a) (obviously) What am I doing wrong?
b) (more interestingly from my point of view): How to figure out what I’m doing wrong.

To b) I tried verbose output, but no output produced. Tried attaching a debugger to the gradle process, but couldn’t find source code to set breakpoints in :slight_smile:

Please help discuss.gradle.org, you’re my only hope :slight_smile:

ps: the code in question is in https://github.com/ostelco/ostelco-core/tree/features/ostelco-lib/ostelco-lib, it’s a work in progress for a simple helper library for writing some applications we’re writing in the ostelco project (very new, not yet very mature open source project).

Best wishes

Bjørn

a) You do nothing wrong :slight_smile:. The install task doesn’t depend on build task (see https://docs.gradle.org/current/userguide/maven_plugin.html#sub:installing_to_the_local_repository). If you execute gradle install you will see your artifacts in your local maven repo.
b) I think your colleague has this artifacts already in his repo. Try to delete or move then and after that run gradle build. I guess his ~/.m2/repository will not contain the files.

You can add following line to your build.gradle

...
build.finalizedBy("install")
...

Then install task will be executed after build task.

Hi Nerro. Thank you for your reply. I tried what you suggested, but it didn’t help. My colleague tried again and it did work for him. We even tried to remove the thing from the .m2/repository on his machine and it still worked. So something else is going on.

Do you know how I can make Gradle more verbose about what it is doing, and not doing, so that I could run “gradle install” on my machine and on my colleague’s machine and compare non-empty outputs?

You can take a look on https://docs.gradle.org/current/userguide/comparing_builds.html.

But about your original issue: your colleague and you execute gradle build and then the build artifact will be deployed in his local repo? Do you have the same version of Gradle or same state of repository? I think this could be the cause.

Can you post the output of gradle --version and git log --name-status HEAD^..HEAD? Do your colleague have something in USER_HOME/.gradle/, USER_HOME/.gradle/init.d folders?