以下是使用 Gradle 2.x 执行此操作的方法:
task copyToLib(type: Copy) {
// into "build/lib"
into "lib"
from configurations.classpath
}
Run Code Online (Sandbox Code Playgroud)
我不确定这是否是正确的方法,但要将 jar 复制到 lib 目录,我执行以下操作:
/**
* Copies the dependencies to the lib directory in preparation for them to be added to a jar file
*/
task copyRuntimeDependencies(dependsOn: configurations.runtime.buildArtifacts, type: Copy)
{
into('build/output/lib')
from configurations.runtime
from configurations.runtime.allArtifacts*.file
}
Run Code Online (Sandbox Code Playgroud)