0

I am a new Gradle user. My task is to build a Gradle based project and then copy the final jar along with its dependencies jars to a remote host.

My approach is to do a local build, and then copy dependencies jars from caches to a local directory with a gradle task, which looks like:

task copyDependencies(type: Copy) {
  from configurations.runtime
  into "build/libs/deps"
}

But this task copies all the dependencies, say including transitive dependencies to the target directory; moreover, the runtime group include compile dependencies by default. So I would like to exclude the transitive dependencies, which takes great amount of space and the compile time dependencies jars. Is there any solution?

At last I plan to copy the generated jar and dependencies jars to a remote host by means of ssh, but I guess there should a way to directly finish this by means of a gradle task

Faithfully hope someone can give some useful hint

Rui
  • 3,454
  • 6
  • 37
  • 70

1 Answers1

0

you need to create a fatJar, you can find an example on how to do it here:

Building a uberjar with Gradle

For copying to a remote directory you can get an example using an ant task here :How to copy directory via scp within gradle task?

Or alternatively you can use an Exec task which will an external tool (scp for example) : https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html

Hope this helps

Community
  • 1
  • 1
seb-c
  • 29
  • 5