Declaring (mutual) exclusive content for more than 1 repository

Hi! As described in the documentation, the possibility exists to declare repositories and what content they have. I’d like to do that for multiple repositories which have mutually exclusive content (Within organisation I work for, in the past every development group published to their own repo).

The documentation only shows one repository. How do I declare multiple repositories, each with it’s own content?

The declaration for one repo with exclusive content from the documentation:

    repositories {
        // This repository will _not_ be searched for artifacts in my.company
        // despite being declared first
        jcenter()
        exclusiveContent {
            forRepository {
                maven {
                    url "https://repo.mycompany.com/maven2"
                }
            }
            filter {
                // this repository *only* contains artifacts with group "my.company"
                includeGroup "my.company"
            }
        }
    }

An ExclusiveContentRepository, which is created by exclusiveContent { ... }, can be defined multiple times, just like other repository types. Same as you could list multiple maven { url '...' } repositories, you can list multiple exclusiveContent { ... } repositories with their own rules per set of repositories. It’s effectively a composite. This is easier to see in the documentation for RepositoryHandler rather than the user guide examples.

1 Like