I’ve found Docker provides a simple approach to building plugins and navigating their Gradle, Groovy and Java dependencies.
Keeps your environment clean and if you need to build plugins compatible with different versions of Morpheus it’s helpful there too.
If your project includes build wrappers, as many do, you’ll still need a compatible version of Java available locally, but using Docker, this approach negates the need for Java also. If you have no build wrappers in your project, Docker will do all the heavy lifting for you.
### Build command - swap tag depending on Gradle/Java version required
docker run -it --rm -u root -v $(PWD):/home/gradle/build-project -w /home/gradle/build-project gradle:8.5-jdk11 gradle build
### Optional - move the plugin and cleanup build artifacts on local system
### This is for Linux/MacOS
cp ./build/libs/* ./plugin/.
rm -r ./build
Add to a Makefile, Bash or Batch file.
Hopefully, this will help others take their first steps with plugin development. And maybe even make things a trifle easier for the more experienced.
Have a great 2024!