Gradle equivalent to Maven's “copy-dependencies”?

后端 未结 4 827
甜味超标
甜味超标 2020-12-01 16:20

In Maven-land, anytime I want to simply pull down the transitive dependencies for a particular POM file, I just open a shell, navigate to where the POM is located, and run:<

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 16:43

    There's no equivalent of copy-dependencies in gradle but here's a task that does it:

    apply plugin: 'java'
    
    repositories {
       mavenCentral()
    }
    
    dependencies {
       compile 'com.google.inject:guice:4.0-beta5'
    }
    
    task copyDependencies(type: Copy) {
       from configurations.compile
       into 'dependencies'
    }
    

    Is it worthwhile to do a contribution? AS You can see it's really easy to do, so I don't think so.

    EDIT

    From gradle 4+ it will be:

    task copyDependencies(type: Copy) {
      from configurations.default
      into 'dependencies'
    }
    

提交回复
热议问题