Maven 'parent' projects counterpart in gradle?


(Wujek Srujek) #1

Hi. Maven supports the concept of a ‘parent pom’, where the parent is just a pom project that defines common configuration (like company wide repositories), dependencies and properties. Then, within the company, projects can point to it (when it is in the company repo) and reuse that information. In my current company it is actually the standard way of doing things; there is a maven-library-parent and maven-webapp-parent and so on.

In gradle, my idea would be to create a common script, deploy it somewhere so that it is accessible via http get requests, and then, in scripts, use: apply from: ‘http://ourserver/library-parent

or similar. The problems I see: 1. the url is hardcoded, whereas in maven I would just define the groupId, the artifactId and version - the infrastructure can deal with grabbing the correct repo (like defining it in the settings.xml file once), but I guess this can be dealt with with some gradle settings file as well? 2. I don’t know whether apply from can deal with http urls, but judging by the docs, it can

Is there any canonical way of doing it in gradle? Does anybody see something wrong with this approach, like maybe that I don’t need to do it because there is something great in gradle that makes it unnecessary?

Regards, wujek


(Peter Niederwieser) #2

A common approach is to use a script plugin (‘apply from: …’) or binary plugin (‘apply plugin: …’) that gets applied to the build’s root project. The former does support HTTP URLs. I would argue that outsourcing the URL into something equivalent to Maven’s ‘settings.xml’ is a change for the worse because it then becomes a per-user setting that can no longer be maintained centrally in version control.


(Wujek Srujek) #3

True, I forgot about the ability to create a plugin that can apply other plugins, create tasks and the like. Thanks for your answer.