Jenkins supports building Java projects since its inception, and for a reason! It’s both the language Jenkins is written in, plus the language in use by many if not all the projects Kohsuke Kawaguchi wanted to watch out when he created the tool many years ago.
If you want to build a Java project, there are a bunch of different options. The most typical ones nowadays are generally Apache Maven, or Gradle.
In any FreeStyle job, as currently Maven is supported in standard, you can use the dedicated step. One advantage is, as for all Jenkins tools, that you can select a specific Maven version and have Jenkins automatically install it on the build node it’s going to run on.
As the associated plugin is not installed by default, first install the Gradle plugin. Once done, you should be able to add a Gradle step.
publishes JUnit XML formatted test reports for trending and analysis
support invoking Gradle as a build step and listing executing tasks per build
collects compiler warnings and issues from static analysis tools such as SpotBugs and PMD
publish and trend code coverage reports from Cobertura
integrate reporting from the SonarQube code quality/inspection platform
adds features for resolving artifacts from a Maven repository such as Nexus or Artifactory.