JFrog’s [BinTray] (https://bintray.com/) appears to be an attempt at providing a social approach to distribution of open source binaries. In many ways, their Java-oriented JCenter repository can be viewed as an alternative to Maven Central. I would like for there to be an easy way to declare in a Gradle build that I would like to use JCenter as a repository. What are the preferred ways to do so, both with existing released versions of Gradle, and in the future?
Ideally, I’d like it to be a standard part of the DSL. For example, something like this could work:
I’ve taken a quick pass at adding support for that to Gradle core, and gotten it working here.
I think that this approach would be what most people want and expect. One main “gotchas” I see are that it requires adding a new method to the RepositoryHandler interface (oh, if only we had defender methods). Another is the possibility of change to the JCenter itself (its URL, availability, etc.), which I don’t know how to judge, given that I’m not part of JFrog, and it’s still a beta service.
JFrog’s tweet indicates they may be working on something along these lines.
In terms of other approaches applicable right now, I know that you can declare JCenter as a mavenRepo with the URL, like this:
You could use an init script to add this automatically to a build (as part of a custom Gradle distribution pulled down by the Gradle wrapper if desired).
Another approach would be to extract logic relating to BinTray into a plugin. The simplest such plugin would just add a repository definition automatically upon application. A more complex plugin might add a “bintray” extension; something like this:
repo(userName: ‘davidmc24’, repoName: ‘myRepo’)
This approach could easily handle both JCenter as well as other repositories. However, you run into a bit of a bootstrapping problem, in that you then would need to acquire the plugin from somewhere other than BinTray. The path of least resistance would seem to be to publish the plugin to Maven Central.
So, all that being said… are there other approaches that I should consider? Which approaches are recommended?