Can I use Gradle to suck up a bunch of jars into a Maven local repo?

I have a project that has dependencies on a couple of dozen proprietary jars. These currently live in a directory on the file system and are incorporated into a gradle build by means of the flatdir construct:

repositories {
   flatDir {
       dirs '/home/usrname/SDK/lib/', '/home/usrname/mstrweb/WEB-INF/lib/'

Instead of this, we should like to be able to write a one-time gradle script that would scarf up all these dependencies and add each one to a local maven repository with a specified group id and version number. Then we could depend on mavenLocal() from then on.

I’ve gotten this far:

dependencies {
    // these are all jars found in one of the directories listed above.
    runtime name: 'abc'
    runtime name: 'defg'
    runtime name: 'hij'
version '10.2'
publishing {

    configurations.runtime.files { c->
    publications {
        mavenJava(MavenPublication) {
            groupId 'com.vendor'
            version '10.2'

//    println

It doesn’t work. It adds a pom file for the first dependency on the list to the maven repo and then stops.

Is there an easy way to use Gradle to scarf all these dependencies up into our local maven repo?

If you’re not married to Maven you might want to check out the ivypot plugin.

I guess I would ask: What is the point exactly? Using real artifact dependencies in a repo is obviously better, but just stuffing things into mavenLocal doesn’t seem that much better than a local flatdir.

The advantages would be that others besides the user in question could access them. We could put them in a public directory, but also we’d like to put them in our corporate repository so that developers could access them from Eclipse as well, and they are going to set up a private repository for us to keep access restricted to our team. So the question boils down to having an easy way to scarf up a directoryful of jars and put them in a repo.

Ok, it just sounded like you weren’t going to go further than just putting them in mavenLocal. If you’re going “all the way”, just have one person upload all the jars to Nexus Pro (which I happen to know you’re using :slight_smile: ) and have it autocreate the POM for each. The process would be somewhat manual, but it couldn’t take more than a couple of hours to upload a directory full of jars.

If the manual process is too painful for some reason, Nexus does have an API, even for uploading artifacts, but you’d have to have a large number of artifacts for that to be worth it (and only if you had to do that more than once).