Building all dependencies from source (vendoring) and produce jars for each

I apologize if it would look like a duplicate with the question here Using git dependency (non gradle based project) in versionCatalogs using gradle - Stack Overflow . It didn’t occur to me that dedicated forum is a better place to ask.

I am working on a project and have a number of dependencies which do not publish their build artifacts. So I am looking for an approach where I can use gradle to

  1. checkout source for all dependendencies into separate directories
  2. define modules for each dependency
  3. build jar file for each
  4. use the jar files during the build of app itself
  5. publish all jar files to internal maven repository to use in production

I don’t have control over the build systems used by dependencies. So I want to avoid the solutions which require modification of files in the checkout directories.

The first library I wanted to include that way is zio-nio. I tried the approach outlined in GitHub - iilyak/gradle-lib-problem: https://stackoverflow.com/questions/70942703/using-git-dependency-non-gradle-based-project-in-versioncatalogs-using-gradle. However soon enough I hit a problem with it which led me to the question I asked on stackoverflow I linked earlier.

The approach I tried is:

settings.gradle

enableFeaturePreview "VERSION_CATALOGS"
enableFeaturePreview "TYPESAFE_PROJECT_ACCESSORS"

def scalaVersion = "2.13"

dependencyResolutionManagement {
    repositories {
        mavenCentral()
        flatDir {
            dirs 'deps'
        }
    }
    versionCatalogs {
        libs {
            version('zio', '2.0.0-M6-2')
            alias('scala-library').to("org.scala-lang:scala-library:$scalaVersion")

            // This dependency is used by the application.
            alias('guava').to('com.google.guava:guava:30.1.1-jre')
            alias('zio').to('dev.zio' , "zio_$scalaVersion").versionRef('zio')
            alias('zio-nio').to("dev.zio:zio-nio_$scalaVersion:2.0")
        }
    }
}

rootProject.name = 'test'
include ':experiments'

build.gradle


plugins {
    id('scala')
}


sourceSets {
    nio.scala.srcDir 'deps/zio-nio/nio/src/main/scala'
}

dependencies {
    module('dev.zio:zio-nio_2.13.7:2.0') {
        implementation(libs.zio)
        implementation fileTree(dir: 'deps/zio-nio')
    }
}

experiments/build.gradle

plugins {
    id 'scala'
    id 'application'
}

group = "test.experiments"

dependencies {
    implementation(libs.zio)
    implementation(libs.zio.nio)
    implementation(libs.scala.library)
}

An additional requirement I forgot to mention is I want to use versionCatalogs or something similar to specify versions of dependencies in one place and apply it to multiple subprojects.