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: 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:


enableFeaturePreview "VERSION_CATALOGS"

def scalaVersion = "2.13"

dependencyResolutionManagement {
    repositories {
        flatDir {
            dirs 'deps'
    versionCatalogs {
        libs {
            version('zio', '2.0.0-M6-2')

            // This dependency is used by the application.
            alias('zio').to('dev.zio' , "zio_$scalaVersion").versionRef('zio')
} = 'test'
include ':experiments'


plugins {

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

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


plugins {
    id 'scala'
    id 'application'

group = "test.experiments"

dependencies {

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.