Punter Vicky
Punter Vicky

Reputation: 17032

Import Maven Project as Dependency into Gradle Project

I went through this link to import a gradle project as dependency into another gradle project. Is there a way to include a maven project as dependency into a gradle project?

Upvotes: 1

Views: 4452

Answers (2)

LazerBanana
LazerBanana

Reputation: 7221

To use the solution described on the link that you provided - both projects must be gradle and included in gradle settings. Therefore you can use project closure to compile and depend on the project without building it explicitly.

I am not aware of any way to do this with maven project. I understand you use some maven plugins that you dont want to rewrite in gradle as simply can not find any equivalents etc. Often had that problem.

In this scenario I would suggest to build maven project and depend on a built jar in your gradle project.

Otherwise you could probably amend sourcesets in your gradle project to include maven classes. But I think it would be to complicated.

If I would be you I would turn it into gradle and try to replicate what you had using maven or just build the artifact and depend on it in dependencies closure.

Gradle is not that new anymore and there are many plugins that are superseding old good maven stuff.

Upvotes: 1

David M. Karr
David M. Karr

Reputation: 15235

If that Maven project is built somewhere else and deployed to a Maven repository, you can specify the artifact it produces as a simple compile dependency. If this Maven project is somehow a subproject of a Gradle multi-project build, I suppose you could hack it to work by simply ignoring the Maven POM file and perhaps adding a build.gradle to that project.

Upvotes: 2

Related Questions