如何将依赖库导出到目录以便在gradle中进行部署?

Jos*_*hua 6 build-automation gradle

我需要将我的代码部署到另一台机器上.如何将依赖jar导出到lib目录?

dja*_*fan 5

以下是使用 Gradle 2.x 执行此操作的方法:

task copyToLib(type: Copy) {
    // into "build/lib"
    into "lib"
    from configurations.classpath
}
Run Code Online (Sandbox Code Playgroud)


Sha*_*der 3

我不确定这是否是正确的方法,但要将 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)