javagradlecompositionmulti-module

Gradle - How to build 2 multimodule projects together? (or a module from other project)


How to build 2 multimodule projects together? (or a module from other project)

I came back to gradle after not using for couples of years and wanted to compile more modules together But those modules have own settings.gradle, so it looks like gradle considers them fully independent project that can't be mixed. At least I get error when I try.

The example project https://github.com/emeraldpay/polkaj

I add examples to be compiled together

// compiling 6 examples together with the polkaj library
include(':balance')
project(':balance').projectDir = file('./examples/balance')
include(':encoding')
project(':encoding').projectDir = file('./examples/encoding')
include(':keys')
project(':keys').projectDir = file('./examples/keys')
include(':rpc')
project(':rpc').projectDir = file('./examples/rpc')
include(':runtime-explorer')
project(':runtime-explorer').projectDir = file('./examples/runtime-explorer')
include(':types')
project(':types').projectDir = file('./examples/types')

But then get errors like

Project 'MyProject' not found in root project 'MyProject'.

Android: Project 'MyProject' not found in root project 'MyProject'

How to build 2 multimodule projects together? (or a module from other project)


Solution

  • This sounds like a job for Composite Builds:

    https://docs.gradle.org/current/userguide/composite_builds.html

    https://docs.gradle.org/current/samples/sample_composite_builds_basics.html