Gradle is a sophisticated Java build system that uses a Groovy-based domain specific language. It is very flexible but this also makes it more difficult to package Gradle projects for Debian. It is possible for Gradle projects to use conventions but most of them look very different. Gradle is also known for frequent incompatibilities which is why upstream recommends to depend on a certain version of Gradle to avoid that kind of breakage. Packaging multiple versions of Gradle is not very Debian-like though because it leads to code duplication, more maintenance burden and possibly more security risks.
You will have to patch the build.gradle file most of the time, to remove unneeded plugins or make the build system Debian compliant, e.g. prevent any downloads from the internet at build time and use system libraries instead. The gradle-debian-helper package will help you to transform build-dependencies from Maven Central into local Debian coordinates in /usr/share/maven-repo. By adding a debian/maven.rules file it is possible to change groupId, artifactId or version similar to Maven based projects.
If you have a choice, we recommend to use a different build system like Ant or Maven which are better supported in Debian and are more stable when it comes to Debian Java packaging.
The mongo-java-driver library is a typical Gradle-based library. In debian/rules you can specify --with buildsystem=gradle to make sure that the Gradle build system is used.
It uses maven_repo_helper to provide Maven artifacts. The debian/libmongodb-java.poms file installs the jars with the --artifact option into /usr/share/maven-repo but also into /usr/share/java (with --java-lib)
Please note that mongo-java-driver uses gradle-debian-helper. This means you can use a debian/maven.rules file to override Maven coordinates.
This library is another very simple example of a Gradle-based library project. Similar to mongo-java-driver it uses maven-repo-helper to install Maven artifacts into /usr/share/maven-repo. Since the project did not provide a pom.xml file, it was downloaded from Maven Central and added to the debian directory.
syncany ( a Gradle-based application)
Syncany is a cloud storage and filesharing application. It is not ready for prime time yet but it also uses gradle-debian-helper to override Maven coordinates and is a good example of a typical Gradle-based application project.
Please note that you can omit compilation steps in debian/rules by using the -x option.
dh_auto_build -- installDist -x test
dh_auto_build will automatically recognize the Gradle build system and execute the installDist build step. However it is also smart enough to exclude the test build step. Just pass -x test.
Syncany is also an example of a Gradle-based project that installs its own startup script, which is patched by Debian. Symlinks are managed by the debian/links file, jar files are installed with install files. In this case there is no need to modify the MANIFEST attribute or to use jarwrapper or java-wrappers.