Wednesday, February 14, 2018

How to get a list of file names from gradle runtime dependencies

If you need a list of file names from runtime (or other type of) dependencies, this is one way to do it:

def files = []
    configurations.runtime.files.forEach() { f ->
    files += f.name
}

The list can be helpful if you need to put it as a Class-Path attribute of JAR manifest file:

jar {
    manifest {
        def files = []
        configurations.runtime.files.forEach() { f ->
            files += f.name
        }
        attributes("Class-Path": files.join(' '))
    }
}

No comments:

Post a Comment