Configure jar task from java plugin


I was using the java plugin and now I need to use the task jar that provides to create an executable from the project itself.

The issue is that I need to customise where is stored the jar file, and I have noticed that It is using the property destinationDirectory to know where to store the file but I can’t set a new value for this property(Jar - Gradle DSL Version 8.0.2)

I have tried in many ways to configure that task through the build.gradle file but I was not able, like this one:

Do anyone knows how to configure the task?
Any help will be appreciated,

Already solved through setting this into the build.gradle file:
destinationDirectory.set(new File(“…”))

Make sure to not have a relative path as argument to new File(...). That would depend on the current working directory and that is not necessarily the project directory. You probably more want something like .set(layout.buildDirectory.dir("foo")).

1 Like

Yes, It will be better,