Adding repositories in contrib module composer.json? Is it possible to add repositories from a module's composer.json instead of a project's composer.json? I've got the following set up:


Commerce Recurly (sandbox)  - and its composer.json
Recurly module fork (sandbox) - and its composer.json
Recurly API fork


I'm developing Commerce Recurly and am declaring a dependency on the Recurly module. However, the Recurly module uses API v2, and I am using API v3 in Commerce Recurly. Since the namespacing of the two APIs are different there are no conflicts when running them concurrently, so I created a fork of the API v2 to allow both to be added to my project. The result is that I am able to get both recurly/recurly-client and mrweiner/recurly-client-php-v2 concurrently installed to vendor.

Composer picks up all of the require dependencies correctly from both modules' composer.json files, as well as the patches from the Recurly Fork. It doesn't seem to pick up the repositories sections, though.

I'd expect to be able to just add the Commerce Recurly repo to my project's main composer.json like so and have everything install when running composer require sandbox/commerce_recurly:

    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "commerce_recurly_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131465"
        },
    }


This doesn't work, though. I need to add repository entries for all three repos to my project's main composer.json to get composer require sandbox/commerce_recurly to correctly install everything, like so:

    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "commerce_recurly_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131465"
        },
        "recurly_fork_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131471"
        },
        "recurly_api_v2": {
            "type": "package",
            "package": {
                "name": "mrweiner/recurly-client-php-v2",
                "version": "2.12.13",
                "type": "vendor",
                "source": {
                    "url": "https://github.com/mrweiner/recurly-client-php.git",
                    "type": "git",
                    "reference": "c9f67565"
                }
            }
        },
    }


Is there some way to get composer to pick up the repositories defined in the modules' composer.json files? Having these extra entries isn't a huge deal for me right now, but when I move Commerce Recurly from Sandbox to a full project, it's going to be inconvenient to force people to add extra Repos to get things running.
Comments above pretty much answer this. No what I was looking to do is not possible.