Composite build not working despite correct artifact

I’m trying to get a basic composite builds example working, and I’m having troubles. I’m using Gradle 8.6.

I have two projects: project-a and project-b. Project A is the consumer, project B is supposed to be a library.

Project A settings.gradle.kts:

plugins {
    id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}

rootProject.name = "project-a"
include("app")
includeBuild("../project-b")

Project A build.gradle.kts:

plugins {
    alias(libs.plugins.jvm)
    application
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.sample:project-b:0.1.0")
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21)
    }
}

application {
    mainClass = "org.example.AppKt"
}

tasks.named<Test>("test") {
    useJUnitPlatform()
}

Project B settings.gradle.kts:

plugins {
    id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}

rootProject.name = "project-b"
include("lib")

Project B build.gradle.kts:

plugins {
    alias(libs.plugins.jvm)
    `java-library`
}

group = "org.sample"
version = "0.1.0"

repositories {
    mavenCentral()
}

dependencies {
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(8)
    }
}

tasks.named<Test>("test") {
    useJUnitPlatform()
}

Here is result of a build scan on project A:

./gradlew build --scan --info
Initialized native services in: C:\Users\...\.gradle\native
Initialized jansi services in: C:\Users\...\.gradle\native
Received JVM installation metadata from 'C:\Program Files\Eclipse Adoptium\jre-21.0.2.13-hotspot': {JAVA_HOME=C:\Program Files\Eclipse Adoptium\jre-21.0.2.13-hotspot, JAVA_VERSION=21.0.2, JAVA_VENDOR=Eclipse Adoptium, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=21.0.2+13-LTS, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=21.0.2+13-LTS, VM_VENDOR=Eclipse Adoptium, OS_ARCH=amd64}
Found daemon DaemonInfo{pid=14848, address=[0c6de890-8a49-4572-a2d8-349f9aed7335 port:64672, addresses:[/127.0.0.1]], state=Idle, lastBusy=1715031218016, context=DefaultDaemonContext[uid=20d733b1-36a1-466a-861f-928dcdd135f5,javaHome=C:\Users\...\.jdks\temurin-1.8.0_412,daemonRegistryDir=C:\Users\...\.gradle\daemon,pid=14848,idleTimeout=10800000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=-XX:MaxMetaspaceSize=384m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=windows-1252,-Dusjava.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=384m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=20d733b1-36a1-466a-861f-928dcdd135f5,javaHome=C:\Users\...\.jdks\temurin-1.8.0_412,daemonRegistryDir=C:\Users\...\.gradle\daemon,pid=14848,idleTimeout=10800000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=-XX:MaxMetaspaceSize=384m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]

  Looking for a different daemon...
Removing 0 daemon stop events from registry
Previous Daemon (3760) stopped at Mon May 06 16:29:09 CDT 2024 after being idle for 0 minutes and not recently used and to reclaim system physical memory
Previous Daemon (8532) stopped at Mon May 06 16:31:48 CDT 2024 after being idle for 2 minutes and not recently used and to reclaim system physical memory
Previous Daemon (23884) stopped at Mon May 06 16:32:10 CDT 2024 after being idle for 0 minutes and not recently used and to reclaim system physical memory
Previous Daemon (20968) stopped at Mon May 06 16:32:30 CDT 2024 after being idle for 0 minutes and not recently used and to reclaim system physical memory
Previous Daemon (28380) stopped at Mon May 06 16:33:04 CDT 2024 after being idle for 0 minutes and not recently used and to reclaim system physical memory
Previous Daemon (26348) stopped at Mon May 06 16:33:57 CDT 2024 after being idle for 0 minutes and not recently used and to reclaim system physical memory
Starting a Gradle Daemon, 1 incompatible and 6 stopped Daemons could not be reused, use --status for details
Starting process 'Gradle build daemon'. Working directory: C:\Users\...\.gradle\daemon\8.6 Command: C:\Program Files\Eclipse Adoptium\jre-21.0.2.13-hotspot\bin\java.exe --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\...\.gradle\wrapper\dists\gradle-8.6-bin\afr5mpiioh2wthjmwnkmdsd5w\gradle-8.6\lib\gradle-launcher-8.6.jar -javaagent:C:\Users\...\.gradle\wrapper\dists\gradle-8.6-bin\afr5mpiioh2wthjmwnkmdsd5w\gradle-8.6\lib\agents\gradle-instrumentation-agent-8.6.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.6
Successfully started process 'Gradle build daemon'
An attempt to start the daemon took 0.933 secs.
The client will now receive all logging from the daemon (pid: 27052). The daemon log file: C:\Users\...\.gradle\daemon\8.6\daemon-27052.out.log
Starting build in new daemon [memory: 512 MiB]
Using 16 worker leases.
Received JVM installation metadata from 'C:\Program Files\Eclipse Adoptium\jre-21.0.2.13-hotspot': {JAVA_HOME=C:\Program Files\Eclipse Adoptium\jre-21.0.2.13-hotspot, JAVA_VERSION=21.0.2, JAVA_VENDOR=Eclipse Adoptium, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=21.0.2+13-LTS, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=21.0.2+13-LTS, VM_VENDOR=Eclipse Adoptium, OS_ARCH=amd64}
Watching the file system is configured to be enabled if available
Now considering [C:\Users\...\Projects\project-a] as hierarchies to watch
File system watching is active
Starting Build
Transforming foojay-resolver-0.7.0.jar (org.gradle.toolchains:foojay-resolver:0.7.0) with ExternalDependencyInstrumentingArtifactTransform
Transforming gson-2.9.1.jar (com.google.code.gson:gson:2.9.1) with ExternalDependencyInstrumentingArtifactTransform
Downloading https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.16.1/gradle-enterprise-gradle-plugin-3.16.1.pom to C:\Users\...\.gradle\.tmp\gradle_download5496732731277862335bin
Downloading https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.16.1/gradle-enterprise-gradle-plugin-3.16.1.module to C:\Users\...\.gradle\.tmp\gradle_download8736540887769370301bin
Downloading https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.16.1/gradle-enterprise-gradle-plugin-3.16.1.jar to C:\Users\...\.gradle\.tmp\gradle_download16910440680069284851bin
Transforming gradle-enterprise-gradle-plugin-3.16.1.jar (com.gradle:gradle-enterprise-gradle-plugin:3.16.1) with ExternalDependencyInstrumentingArtifactTransform
Settings evaluated using settings file 'C:\Users\...\Projects\project-a\settings.gradle.kts'.
Now considering [C:\Users\...\Projects\project-b, C:\Users\...\Projects\project-a] as hierarchies to watch
Transforming foojay-resolver-0.7.0.jar (org.gradle.toolchains:foojay-resolver:0.7.0) with ExternalDependencyInstrumentingArtifactTransform
Transforming gson-2.9.1.jar (com.google.code.gson:gson:2.9.1) with ExternalDependencyInstrumentingArtifactTransform
Projects loaded. Root project using build file 'C:\Users\...\Projects\project-a\build.gradle'.
Included projects: [root project 'project-a', project ':app']

> Configure project :project-b
Evaluating project ':project-b' using build file 'C:\Users\...\Projects\project-b\build.gradle'.

> Configure project :project-b:lib
Evaluating project ':project-b:lib' using build file 'C:\Users\...\Projects\project-b\lib\build.gradle.kts'.
Caching disabled for Kotlin DSL script compilation (Project/TopLevel/stage1) because:
  Build cache is disabled
Transforming kotlin-gradle-plugin-model-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-api-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-1.9.20-gradle81.jar (org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-idea-proto-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-idea-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-klib-commonizer-api-1.9.20.jar (org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-util-klib-1.9.20.jar (org.jetbrains.kotlin:kotlin-util-klib:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-native-utils-1.9.20.jar (org.jetbrains.kotlin:kotlin-native-utils:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-build-tools-api-1.9.20.jar (org.jetbrains.kotlin:kotlin-build-tools-api:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-android-extensions-1.9.20.jar (org.jetbrains.kotlin:kotlin-android-extensions:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-compiler-runner-1.9.20.jar (org.jetbrains.kotlin:kotlin-compiler-runner:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-compiler-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-compiler-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-compiler-impl-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-annotations-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-project-model-1.9.20.jar (org.jetbrains.kotlin:kotlin-project-model:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-tooling-core-1.9.20.jar (org.jetbrains.kotlin:kotlin-tooling-core:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-util-io-1.9.20.jar (org.jetbrains.kotlin:kotlin-util-io:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-daemon-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming trove4j-1.0.20200330.jar (org.jetbrains.intellij.deps:trove4j:1.0.20200330) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-daemon-client-1.9.20.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-jvm-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-common-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-common:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlinx-coroutines-core-jvm-1.5.0.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0) with ExternalDependencyInstrumentingArtifactTransform
Using Kotlin Gradle Plugin gradle81 variant
kotlin scripting plugin: created the scripting discovery configuration: kotlinScriptDef
kotlin scripting plugin: created the scripting discovery configuration: testKotlinScriptDef
Caching disabled for Kotlin DSL script compilation (Project/TopLevel/stage2) because:
  Build cache is disabled
Starting process 'command 'C:\Users\...\.jdks\openjdk-21.0.2\bin\java.exe''. Working directory: C:\Users\...\.gradle\.tmp\tmp-jvm9195747974091074144probe Command: C:\Users\...\.jdks\openjdk-21.0.2\bin\java.exe -Xmx32m -Xms32m -cp . JavaProbe
Successfully started process 'command 'C:\Users\...\.jdks\openjdk-21.0.2\bin\java.exe''
Received JVM installation metadata from 'C:\Users\...\.jdks\openjdk-21.0.2': {JAVA_HOME=C:\Users\...\.jdks\openjdk-21.0.2, JAVA_VERSION=21.0.2, JAVA_VENDOR=Oracle Corpora
tion, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=21.0.2+13-58, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=21.0.2+13-58, VM_VENDOR=Oracle Corporation, OS_ARCH=amd64}

Starting process 'command 'C:\Users\...\.jdks\temurin-1.8.0_402\bin\java.exe''. Working directory: C:\Users\...\.gradle\.tmp\tmp-jvm1074784811993769941probe Command: C:\Users\...\.jdks\temurin-1.8.0_402\bin\java.exe -Xmx32m -Xms32m -cp . JavaProbe
Successfully started process 'command 'C:\Users\...\.jdks\temurin-1.8.0_402\bin\java.exe''
Received JVM installation metadata from 'C:\Users\...\.jdks\temurin-1.8.0_402': {JAVA_HOME=C:\Users\...\.jdks\temurin-1.8.0_402\jre, JAVA_VERSION=1.8.0_402, JAVA_VENDOR=Temurin, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=1.8.0_402-b06, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=25.402-b06, VM_VENDOR=Temurin, OS_ARCH=amd64} 
Starting process 'command 'C:\Users\...\.jdks\corretto-19.0.2\bin\java.exe''. Working directory: C:\Users\...\.gradle\.tmp\tmp-jvm13991420962167372424probe Command: C:\Users\...\.jdks\corretto-19.0.2\bin\java.exe -Xmx32m -Xms32m -cp . JavaProbe
Successfully started process 'command 'C:\Users\...\.jdks\corretto-19.0.2\bin\java.exe''
Received JVM installation metadata from 'C:\Users\...\.jdks\corretto-19.0.2': {JAVA_HOME=C:\Users\...\.jdks\corretto-19.0.2, JAVA_VERSION=19.0.2, JAVA_VENDOR=Amazon.com Inc., RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=19.0.2+7-FR, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=19.0.2+7-FR, VM_VENDOR=Amazon.com Inc., OS_ARCH=amd64}
Starting process 'command 'C:\Users\...\.jdks\temurin-17.0.10\bin\java.exe''. Working directory: C:\Users\...\.gradle\.tmp\tmp-jvm15931474199558228636probe Command: C:\Users\...\.jdks\temurin-17.0.10\bin\java.exe -Xmx32m -Xms32m -cp . JavaProbe
Successfully started process 'command 'C:\Users\...\.jdks\temurin-17.0.10\bin\java.exe''
Received JVM installation metadata from 'C:\Users\...\.jdks\temurin-17.0.10': {JAVA_HOME=C:\Users\...\.jdks\temurin-17.0.10, JAVA_VERSION=17.0.10, JAVA_VENDOR=Eclipse Adoptium, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=17.0.10+7, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=17.0.10+7, VM_VENDOR=Eclipse Adoptium, OS_ARCH=amd64}
Starting process 'command 'C:\Users\...\.jdks\temurin-1.8.0_412\bin\java.exe''. Working directory: C:\Users\...\.gradle\.tmp\tmp-jvm1213717772726923732probe Command: C:\Users\...\.jdks\temurin-1.8.0_412\bin\java.exe -Xmx32m -Xms32m -cp . JavaProbe
Successfully started process 'command 'C:\Users\...\.jdks\temurin-1.8.0_412\bin\java.exe''
Received JVM installation metadata from 'C:\Users\...\.jdks\temurin-1.8.0_412': {JAVA_HOME=C:\Users\...\.jdks\temurin-1.8.0_412\jre, JAVA_VERSION=1.8.0_412, JAVA_VENDOR=Temurin, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=1.8.0_412-b08, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=25.412-b08, VM_VENDOR=Temurin, OS_ARCH=amd64}
Registering project ':project-b' in composite build. Will substitute for module ':project-b'.
Registering project ':project-b:lib' in composite build. Will substitute for module 'org.sample:lib'.

> Configure project :
Evaluating root project 'project-a' using build file 'C:\Users\...\Projects\project-a\build.gradle'.

> Configure project :app
Evaluating project ':app' using build file 'C:\Users\...\Projects\project-a\app\build.gradle.kts'.
Caching disabled for Kotlin DSL version catalog plugin accessors for classpath '6d292e71577f0fb7afb64c8a7a595d30' because:
  Build cache is disabled
Caching disabled for Kotlin DSL plugin specs accessors for classpath '6d292e71577f0fb7afb64c8a7a595d30' because:
  Build cache is disabled
Caching disabled for Kotlin DSL script compilation (Project/TopLevel/stage1) because:
  Build cache is disabled
Transforming kotlin-gradle-plugin-model-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-api-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-1.9.20-gradle81.jar (org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-idea-proto-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.20) with ExternalDependencyInstrumentingArtifactTransform 
Transforming kotlin-gradle-plugin-idea-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-klib-commonizer-api-1.9.20.jar (org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-native-utils-1.9.20.jar (org.jetbrains.kotlin:kotlin-native-utils:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-util-klib-1.9.20.jar (org.jetbrains.kotlin:kotlin-util-klib:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-build-tools-api-1.9.20.jar (org.jetbrains.kotlin:kotlin-build-tools-api:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-android-extensions-1.9.20.jar (org.jetbrains.kotlin:kotlin-android-extensions:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-compiler-runner-1.9.20.jar (org.jetbrains.kotlin:kotlin-compiler-runner:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-compiler-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-compiler-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-compiler-impl-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-gradle-plugin-annotations-1.9.20.jar (org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-project-model-1.9.20.jar (org.jetbrains.kotlin:kotlin-project-model:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-tooling-core-1.9.20.jar (org.jetbrains.kotlin:kotlin-tooling-core:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-util-io-1.9.20.jar (org.jetbrains.kotlin:kotlin-util-io:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-daemon-embeddable-1.9.20.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming trove4j-1.0.20200330.jar (org.jetbrains.intellij.deps:trove4j:1.0.20200330) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-daemon-client-1.9.20.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlinx-coroutines-core-jvm-1.5.0.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-jvm-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Transforming kotlin-scripting-common-1.9.20.jar (org.jetbrains.kotlin:kotlin-scripting-common:1.9.20) with ExternalDependencyInstrumentingArtifactTransform
Using Kotlin Gradle Plugin gradle81 variant
kotlin scripting plugin: created the scripting discovery configuration: kotlinScriptDef
kotlin scripting plugin: created the scripting discovery configuration: testKotlinScriptDef
Caching disabled for Kotlin DSL accessors for project ':app' because:
  Build cache is disabled
Caching disabled for Kotlin DSL script compilation (Project/TopLevel/stage2) because:
  Build cache is disabled
All projects evaluated.
Task name matched 'build'
Selected primary task 'build' from project :
Resource missing. [HTTP GET: https://repo.maven.apache.org/maven2/org/sample/project-b/0.1.0/project-b-0.1.0.pom]
Could not execute [report metric STATISTICS_COLLECT_METRICS_OVERHEAD]
Could not execute [report metric STATISTICS_COLLECT_METRICS_OVERHEAD]

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:distTar'.
> Could not resolve all task dependencies for configuration ':app:runtimeClasspath'.
   > Could not find org.sample:project-b:0.1.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/org/sample/project-b/0.1.0/project-b-0.1.0.pom
     Required by:
         project :app

* Try:
> If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Get more help at https://help.gradle.org.

What am I doing wrong here?

When you say “Project B build.gradle.kts”, I guess you mean project-b/lib/build.gradle.kts which produces org.sample:lib and not project-b/build.gradle.kts which would produce org.sample:project-b that you declare you need in A. Also have a look at the output of outgoingVariants task for B.