Managing Gradle plugin with Maven

(MJ) #1

I know that this might seem unusual, but can you manage a Gradle plugin project with Maven? Basically, I implemented a Gradle plugin for an existing framework which currently uses Maven builds, and the initial build.gradle I created should be translated to pom.xml. I’m asking this because I can’t seem to find equivalent for compile gradleApi(), which includes local libraries as dependencies (absent in Maven Central).

Does anyone had a similar problem and can provide a minimal pom.xml example?

(Lance Java) #2

Perhaps you could invoke gradle from maven via the gradle-maven-plugin

(MJ) #3

I think it would be better to fully migrate the build to Maven, as the project itself doesn’t invoke or require any specific Gradle tasks. (Unless Gradle does something with the jar other than validation when it detects defined Gradle plugins in resources.) A simple mvn install would be enough, which basically matches gradle build install or gradle uploadArchives, AFAIK.

(Benjamin Muschko) #4

At this time not all of the Gradle API JARs are published to a public Maven repository. This might change in the future though. As a result you won’t be able to declare the Gradle API dependencies in a Maven build.

You can find a similar discussion in this post.

(Stefan Oehme) #5

I agree with @Lance_Java here. Just delegate from your Maven build to Gradle. The Gradle build script for your plugin will be short and simple to understand thanks to the gradleApi() notation.

(MJ) #6

Seems that currently there’s no other choice. I was pretty sure it comes down to missing Gradle API jars, but that’s not the case after all. Anyway, thanks for your help.

(Lance Java) #7

FYI you may do this in conjunction with build-helper:attach-artifact so that the artifact is ‘known’ to maven (for install / deploy etc)