'How to build gradle project before creating a distribution?

I have a gradle 6.x project, where I use the distribution plugin to create .zip distribution. https://docs.gradle.org/6.9/userguide/distribution_plugin.html

I use the following command to create a ZIP dist:

gradle distZip

However, I have some jar files that I need to put inside a distribution, and when only running this command, it creates a basically empty zip file, because these jars would be located at /build/... .

How can I tell the distZip task, to build these jars before packaging, preferably without running tests?

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source