jsphdnl
jsphdnl

Reputation: 425

Building a Fat jar with local dependencies Gradle

I have a build.gradle file as follows

buildscript {
    repositories { jcenter() }
}

dependencies {
    compile 'io.dropwizard:dropwizard-core:0.8.2'
    compile 'io.dropwizard:dropwizard-testing:0.8.2'
}

When I run gradle build it downloads the dropwizard dependencies from maven repository and builds a fat jar. Every time I pull the code in a new development environment it fetches from the maven central repo. But some of the development machines do not have internet access, to build in these machines, I thought if I could create a folder called libs in the source code root folder and use this folder as to load the jar files, like

repositories {
   flatDir {
       dirs 'libs'
   }
}

Is it possible to do? Where to find the downloaded jars from maven central in my local machine, so that I can copy them into the libs folder (dropwizard 0.8.2 jar)

Upvotes: 1

Views: 1457

Answers (1)

Opal
Opal

Reputation: 84756

Yes, it's possible. Create the following task:

task copyLibs(type: Copy) {
   from configurations.compile
   into 'libs'
}

After running this task you'll have a folder libs with all the dependencies (you might need a broader range than just compile - so align the task). You need to check this folder to SCM and commit it.

Of course mind the fact that it won't automatically update the dependencies if you e.g. change the version - you need to do it manually or maybe write a plugin that does all the things you need.

Upvotes: 1

Related Questions