1

I have a project in gradle with a multiproject dependency where it looks like this

Project Big
|--> Project A
|--> Project B
|--> Project C
|--> settings.gradle
// Dynamically include anything with a build.gradle file in the Gradle mutli-project build configuration
fileTree(dir: rootDir, include: '*/**/build.gradle')
    .matching {
        // Eclipse files
        exclude '**/bin/'
        // Gradle files
        exclude '**/build/'
    }
    .each {
        def path = it.parentFile.absolutePath - rootDir.absolutePath
        include(path.replaceAll('[\\\\/]', ':'))    }

And I have another project

Project Small
|--> settings.gradle

And I want to build a dependency to Project Big. I see solutions here

Gradle sync issue : None of the consumable configurations have attributes

Sync shared library projects/modules with its source

But keeps getting with this configuration

Project Small
|--> Project Big
|--> settings.gradle
include ":big"
project(":big").projectDir = file("../project-big/")
No matching configuration of project :big was found. The consumer was configured to find an API of a library compatible with Java 11, preferably not packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - None of the consumable configurations have attributes.

Is it due to the fact I am referencing a multi project module instead of a single project?

Bao Thai
  • 533
  • 1
  • 6
  • 25

1 Answers1

0

You can try composite builds.

Assume there is a subproject project_small/app that wants to use project_big/proj_b:

// project_big/settings.gradle

rootProject.name = 'project_big'
include('proj-a', 'proj-b', 'proj-c')
// project_small/app/build.gradle

plugins {
    id 'java'
}

dependencies {
    implementation 'xxx.ooo.project_big:proj_b'
}

Then use the dependency substitution:

// project_small/settings.gradle

rootProject.name = 'project_small'

includeBuild('project_big') {
    dependencySubstitution {
        substitute module('xxx.ooo.project_big:proj_b') using project(':proj-b')
    }
}
include('app')

Here is a minimal sample project: https://github.com/chehsunliu/stackoverflow/tree/main/a.2021-08-03.gradle.68628691.

chehsunliu
  • 1,559
  • 1
  • 12
  • 22
  • I am curious what is `include('proj-a', 'proj-b', 'proj-c')` when I have the fileTree instated? IncludeBuild is a jar dependency right? Rather than a project reference – Bao Thai Aug 03 '21 at 21:30