Feature request: mavenCentral() like convenience getter for company's internal repository


(Phanindra) #1

Please point out if this already exists or if I was supposed to post this somewhere else.

As of now, the url to our internal repository has to be added to all projects and that’s gradually becoming unpleasant. I was wondering if a convenience method like mavenInternal() would be convenient and improve usability.

How it may work:
mavenInternal() will return a predefined static url (decided by Gradle team) and each company can create an internal dns entry for that url to point to their internal repository.

Support for something like mavenInternal('some-random-suffix-to-be-appended-to-the-static-url') might take it further by supporting multiple internal repository urls (for snapshots, etc.)

Using mavenCentral() vs having to use the explicit url is a great example to illustrate the difference in convenience.

[I guess you would come up with a better name than `mavenInternal()` if you were to proceed at all :slight_smile: ]


(Chris Doré) #2

Here’s some ideas that use repositories.ext How to create custom repository type?

Here’s an example of a plugin using Groovy’s metaClass. https://github.com/Ullink/gradle-repositories-plugin

In addition to adding custom methods to project.repositories in a similar way to that plugin, we’ve been successfully using the following in our plugin’s apply() to add our methods to publishing.repositories:

project.plugins.withType( PublishingPlugin, new Action<PublishingPlugin>() {
    @Override
    void execute( PublishingPlugin publishingPlugin )
    {
        project.extensions.configure( PublishingExtension, new Action<PublishingExtension>() {
            @Override
            void execute( PublishingExtension publishingExtension )
            {
                addOurCustomRepoMethods( publishingExtension.repositories )
            }
        } )
    }
} )