How to include a Maven project as dependency in Gradle

This question was asked on StackOverflow the other day and I came up with a “hackish” solution:

It is possible to fake including a Maven dependency by setting a dependency on the output folder of the Maven project and having it built by Gradle.

Here is an example:

This way Gradle will execute a Maven build (compileMavenProject) before compiling. But be aware that it is not a Gradle “project” in the traditional sense and will not show up, e.g. if you run gradle dependencies. It is just a hack to include the compiled class files in your Gradle project.

You can use a similar technique to also include the Maven dependencies:

See: https://stackoverflow.com/questions/35795250/maven-project-as-dependency-in-gradle-project/35796615#35796615


Tagged #java, #gradle.