Overview
This is an example of using custom Gradle distributions for projects with different setup - we create ‘library’ and ‘service’ distributions and a sample project which uses ‘service’.
Note: java 21 is required
Custom Distributions
custom distribution project configures two custom Gradle distribution - library and service. Both of them use shared setup.
Note: a cool feature of init scripts is that we can apply Gradle plugins from them. Unfortunately, it’s necessary to do that by specifying complete plugin class name - import by plugin id is not supported there (some old Gradle design bug).
Client Project
client project is configured to use the ‘service’ distribution and defines only bare minimum of the configuration.
In Action
- Build custom distribution
pushd custom-distribution; ./gradlew buildGradleDist; popd
- Run the client project
pushd client-project; ./gradlew bootRun; popd
- Call a web server started by the client project and ensure that it works
curl 127.0.0.1:8080/ping Hi there!