Skip to content

Provide Project Isolation compatible way to add dependencies to a project #29037

@martinbonnin

Description

@martinbonnin

Expected Behavior

Make it possible to add a dependency to another project without breaking project isolation.

Maybe in IsolatedProject ?

interface IsolatedProject {
  addDependency(configurationName: String, projectPath: String)
}

Current Behavior (optional)

The 2 use cases I have in mind are kdoc and publishing. In a multi-module project, it's frequent that not all modules require publishing and to have some "aggregating" task in the root project to document/publish the required subprojects.

I currently see 2 solutions.

1. keeping track of the list of projects in the root project

dependencies {
    // List all projects here
    // It feels a bit awkward because I have 2 places to edit when I'm adding a module
    add("aggregatingConfiguration", project(":module1"))
    add("aggregatingConfiguration", project(":module2"))
    // ...
}

2. using a lenient configuration

allprojects.forEach {
  add("aggregatingConfiguration", project(":${it.path}"))
}

Both of these solutions have limitations. 1. requires keeping track of a separate project list which is error prone. 2. might defeat configuration on demand. Also makes it hard to debug issues because some (valid) resolution errors might end up being ignored.
See also this comment that describes the same problem.

Or is there another way?

Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions