This sample demonstrates a multi-project build with Eclipse support. It includes multiple layers of modules that depend on each other and a simple Swing UI for a thick client application.
common
– basic utilities shared across the repolibrary
– library logic depending oncommon
data
– data access usingcommons-io
andcommons-lang3
service
– service layer combiningdata
andlibrary
ui
– Swing user interface depending onservice
app
– runnable entry point assembling everything
gradle build eclipse
Import the project into Eclipse via Buildship after running the eclipse
task.
If you prefer to use the Gradle wrapper, first run gradle wrapper
to
generate the wrapper JAR files.
A simple Dockerfile is provided to run the app in a container:
docker build -t cookbook-app .
docker run --rm cookbook-app
Scripts under scripts/
illustrate how you might package the application
with install4j for Windows. Example:
./scripts/package-install4j.sh
- Run
./gradlew eclipse
and import the project via File ▸ Import ▸ Existing Gradle Project. - In Preferences ▸ Gradle ▸ Synchronization enable Synchronize automatically after builds.
- Launch the
app
run configuration from the Gradle Tasks view. While it runs under the debugger, editing a method signature inlibrary
and saving will trigger HotswapAgent to reload the class. - For instant recompiles run
./gradlew -t classes
in the background so Eclipse picks up new class files immediately.
The book/
directory contains the structure for the Gradle Cookbook. Each chapter includes an outline and a Jupyter notebook so you can experiment with the code.