Help with File Install Task

Hello,

I’ve got my build script working just about perfectly. I had to move to the forked/updated goooler.Shadow plugin for Java 21 compatibility, but I’ve got everything running smoothly now. I’m trying to add one final “install” task to update the fatJar in my user directory. My task looks like this:

tasks.register("install") {
    dependsOn tasks.shadowJar
    def destinationPath = project.gradle.gradleUserHomeDir.path + '/';
    def installJar = 'app-util.jar';
    doFirst {
        System.out.println( "Removing old installed JAR file " + destinationPath)
        delete destinationPath + installJar
    }
    doLast {
        System.out.println( "Installing new output into user directory.")
        copy {
            from shadowJar.outputs.files.singleFile
            into destinationPath
            rename (shadowJar.outputs.files.singleFile.name, installJar)
        }
        System.out.println( "Completed install of: " + shadowJar.outputs.files.singleFile )
    }
}

The issue I’m now facing is that this simply isn’t updating the JAR. I’m running Gradle from a user-space command prompt (Mac), so I think the ability to delete and move the files would be fine. I don’t get any errors when running, so I’m a little unclear on how to debug and figure out how to fix it.

Any advice or guidance would be much appreciated!

Thanks,
E

Can you share a build --scan URL?

Sure thing: Build Scan® activation | Develocity

Thanks!

The build scan shows the task is run and also the printlns are printed.
What makes you think it is not executed?

Well, the JAR doesn’t seem to update as I would expect. It seems to just be stuck.

Well, not much to say from the Gradle side I guess.
Look at the destination folder.
Compare the built jar with the jar in there.

Bjorn, you guessed it.

project.gradle.gradleUserHomeDir.path went to a different directory. I switched to System.properties['user.home'] and everything is working great.

Thank you for the help!

E

It’s Björn or Bjoern, not Bjorn. :wink:

Yeah, the Gradle User Home has nothing to do with your User Home.
Well, not more than that it by default is located inside your User Home and called .gradle, but that does not have to be true.