Is it possible to insert a repository to a specific position in the list?

I have a few repositories through which dependencies can be found however I only want to add 1 of them (mavenLocal) if certain tasks are not in the task graph. I also want this one to win in the event of clashes which means I need to add this one first.

This presents a problem as the mavenLocal() method adds it to the end of the list and I can only add this repository when the task graph is ready which means I need to defer adding the other repositories too (and this causes a problem with jacoco configuration which I need resolve to construct the required javaagent path for configuring the test task).

It seems I need something like the ability to tell it to add mavenLocal “first”. This seems feasible as there is an ‘addFirst’ method on ‘ArtifactRepositoryContainer’ but creating mavenLocal needs the ResolverFactory which appears to be internal hence not publicly accessible. Is there something I’m missing here?

Alternatively is there another way to achieve what I need?

Cheers Matt

Repositories can be inserted at arbitrary positions. The question is whether a Maven local repository can be created without adding it to the list. At first sight, the only way I can see is to use something like ‘addFirst(“file:///path/to/local/repo”)’.