Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle composite build. Project not found. includeBuild not working?

I have 2 projects, my-app and string-utils. My-app depends on string-utils. When building my-app I get:

"Project with path ':string-utils' could not be found in root project 'my-app'

Shouldn't includeBuild work here?

My Gradle scan is here.

├── my-app
│   ├── build
│   ├── build.gradle
│   ├── settings.gradle
│   └── src
└── string-utils
    ├── build
    ├── build.gradle
    ├── settings.gradle
    └── src

/my-app/settings.gradle:

rootProject.name = 'my-app'
includeBuild '../string-utils'

/my-app/build.gradle:

plugins {
    id 'java'
    id 'application'
    id 'idea'
}
group "org.sample"
version "1.0"
application {
    mainClassName = "org.sample.myapp.Main"
}
dependencies {
  implementation project(':string-utils')
}
repositories {
    jcenter()
}

/string-utils/settings.gradle:

rootProject.name = 'string-utils'

When running:

/my-app$ gradle build --scan --info

Initialized native services in: /home/andrew/.gradle/native
The client will now receive all logging from the daemon (pid: 202204). The daemon log file: /home/andrew/.gradle/daemon/6.2.1/daemon-202204.out.log
Starting 4th build in daemon [uptime: 38 mins 14.32 secs, performance: 99%, non-heap usage: 20% of 268.4 MB]
Using 128 worker leases.
Starting Build
Compiling settings file '/tmp/5/my-app/settings.gradle' using BuildScriptTransformer.
Settings evaluated using settings file '/tmp/5/my-app/settings.gradle'.
Projects loaded. Root project using build file '/tmp/5/my-app/build.gradle'.
Included projects: [root project 'my-app']
[composite-build] Configuring build: /tmp/5/string-utils

Configure project :string-utils
Evaluating project ':string-utils' using build file '/tmp/5/string-utils/build.gradle'.
Registering project ':string-utils' in composite build. Will substitute for module ':string-utils'.

Configure project :
Evaluating root project 'my-app' using build file '/tmp/5/my-app/build.gradle'.
Compiling build file '/tmp/5/my-app/build.gradle' using SubsetScriptTransformer.
Compiling build file '/tmp/5/my-app/build.gradle' using BuildScriptTransformer.

FAILURE: Build failed with an exception.

* Where:
Build file '/tmp/5/my-app/build.gradle' line: 19

* What went wrong:
A problem occurred evaluating root project 'my-app'.

Project with path ':string-utils' could not be found in root project 'my-app'.
like image 941
Andrew Avatar asked Feb 27 '20 18:02

Andrew


People also ask

Should I use Gradle buildsrc or composite builds?

Use composite builds instead | by Josef Raska | ProAndroidDev Stop using Gradle buildSrc. Use composite builds instead You are invalidating the whole project for any change within buildSrc, usually without there being a valid reason. We can keep the sweetness of Kotlin whilst avoiding this.

What does includebuild () do in Gradle?

The string argument to includeBuild () is the path to the Wire directory that contains its settings.gradle.kts file. The rest is a list of dependency substitutions. The module argument is a Maven coordinate without its version. The project argument is the Wire subproject that produces that artifact.

How do I stop Gradle from using buildsrc?

Stop using Gradle buildSrc. Use composite builds instead You are invalidating the whole project for any change within buildSrc, usually without there being a valid reason. We can keep the sweetness of Kotlin whilst avoiding this. buildSrc is a directory at the Gradle project root, which can contain our build logic.

How do I replace a project dependency in Gradle?

The algorithm for doing this is very simple: Gradle will inspect the group and name for the projects in the included build, and substitute project dependencies for any external dependency matching $ {project.group}:$ {project.name}. By default, substitutions are not registered for the main build.


1 Answers

Fixed. Needed to replace

implementation project(':string-utils')

with

implementation "org.sample:string-utils"
like image 172
Andrew Avatar answered Oct 27 '22 01:10

Andrew