How to Copy dependencies to Build directory in Gra

2019-06-11 17:16发布

问题:

How to Copy dependencies to Build directory in Gradle without adding any tasks in build.gradle like mvn dependency:copy-dependencies..

回答1:

If you really don't want a task for this you could use the copy method of the project object.

configurations {
    compile
}

dependencies {
    compile 'someGroup:someArtifact:someVersion'
}

project.copy {
    from project.configurations.compile
    into project.buildDir
}

One noticeable effect of this is that the resolving will be triggered for every invokation i.e. even if you only want to list tasks the resolve and copy will be triggered.