How can I get hold of the Gradle instance of the Repository Factory?

I am experimenting with creating a new kind of repository. By digging through Gradle source I have managed to get past most issues so far albeit by using internal APIs (a matter for another conversation).

I am stuck however at getting to the instance of ‘BaseRepositoryFactory’ which is used by ‘DefaultRepositoryHandler’.

Any suggestions?

I don’t understand the internals of your “new kind of repository” but have you considered creating a HTTP interface which makes the repository act like a maven repository?

That would be cheating in in this instance. Making a remote repository looks like Maven is an option, like in the case of rubygems, but this is not what I am after. It would also assume that the user have the capability of installing something on the server to serve up files via a maven proxy.

I am looking at trying to do something between using ‘ivy’ and ‘flatDir’ - serve up files from a remote server in any kind of directory structure as determined by the pattern layout, but with no dependency information.

If you look at this Gist - https://gist.github.com/ysb33r/9f95bab338b912c45986, it shows how to fake up some of this up using Ivy. The problem with this approach is that one usuallly also have to override the Ivy XML pattern to some non-existent file and the resovler will also try to query for that non-existent file anyway.

Another workaround is to use the VFS gradle plugin as per this Gist - https://gist.github.com/ysb33r/0c534d165863628a07cc. The problem with that is that none of the standard dependency infrastructure is available.

So now I am playing around with writing an artiffact repository. Besides being a good learning excercise, it will also show how much the Gradle API curretnly helps a plugin author in this regard. (Currently not a lot, as I have to play around with a number of internal APIs)

Hopefully that provides better context.

It would also assume that the user have the capability of installing something on the server to serve up files via a maven proxy

Not necessarily, you could have gradle fire up jetty to host the proxy in the same jvm as gradle

That thought has crossed my mind and could be an interesting investigation.

In the mean-time though, I would like to see if there is an answer to my original question.

((ProjectInternal) project).getServices().get(BaseRepositoryFactory.class)

Dirty! But it works.