Skip to content Skip to sidebar Skip to footer

How Can I Use Gradle To Build A Jar With Required Libraries In A Sub-folder (like Eclipse) For Android?

In Eclipse, you can create a project jar with its required dependencies in an adjacent sub-folder by doing ... Export->Java->Runnable JAR file Select Library handling option

Solution 1:

You can create a Gradle task for copying, like so:

task copyLibs(type: Copy) {
    from('path/to/dir/with/lib/jars/')
    into('path/to/subfolder/next/to/generated/jar/')
    include('names.jar','of.jar','jars.jar','to.jar','copy.jar')
}

copyLibs.dependsOn(build)

Edit:

task combinedJar(type: Jar) {
   fromzipTree("path/to/generated.jar")
   from"path/to/subfolder/next/to/generated/jar/"
}

combinedJar.dependsOn(copyLibs)

Run via gradlew copyLibs. You can make the task depend on the build task that builds your project.

Note that you may have to also create the path/to/subfolder/next/to/generated/jar/ in the task.

Post a Comment for "How Can I Use Gradle To Build A Jar With Required Libraries In A Sub-folder (like Eclipse) For Android?"