How to use maven-publish to publish dependencies and transient dependencies

Hello,

My team has a private maven repository that can’t be connected to the internet (its nexus if that matters). Before, to add artifacts to the repository, a team member would go and manually read all the maven POMs to find all the artifacts, and then upload them one-by-one through the web GUI. This is how all the dependencies for the projects were managed.

I thought this was ludicrious so I decided to try and automate this process. After reading around that there really isn’t a turn-key way to make a private maven mirror like can be done with apt, yum, npm, and pip, I thought I would try to do it with Gradle.

To start with, I thought I would try to grab the robolectric library and all of its dependencies in a gradle project on my thumbdrive, then move over to the maven repository and publish all the artifacts into the maven repository. I only got to the point of being able to dump the jars from the dependencies into a folder as can be seen in the build.gradle script I have attached.

Where I am running into problems is with the MavenPublication part, when I try to run $gradle generatePomFileForMavenJavaPublication I don’t get any of the dependencies for robolectric listed in my POM

I was reading through this issue on github which led me to this repository which I think does what I want, but is broken as of Gradle 7.

I don’t know if I am just making this unreasonably hard because I am new to Gradle, or if it is actually this hard to maintain a maven repository without internet connectivity, but I would really appreciate some help.

Thanks,
Wes

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This is a general purpose Gradle build.
 * Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.1/samples
 *
 * NOTE: THIS WAS CREATED IN GRADLE 7.1
 */
plugins {
    id 'distribution' //probably not needed anymore
    id 'application' //probably not needed anymore
    id 'maven-publish'
    id 'java-library' //probably not needed anymore
}

repositories {
    mavenCentral()
    google()
    maven {
        url 'https://mvnrepository.com'
    }

}

dependencies {
    implementation 'org.robolectric:robolectric:4.5.1'
}

//nasty hack from https://stackoverflow.com/questions/47910578/not-able-to-copy-configurations-dependencies-after-upgrading-gradle-plugin-for-a
configurations {
    customConfig.extendsFrom implementation
}

//dumps the jar files for all the dependencies into the folder specified.
task copyLibs(type: Copy) {
    from configurations.customConfig
    into "$project.rootDir/reports/libs/"
}

//complement to copy libs
task cleanLibs(type: Delete){
    delete "$project.rootDir/reports"
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            
        }
    }

    repositories {
        maven {
            name = 'testrepo'
            url = layout.buildDirectory.dir("repo")
        }
    }
}