What's the best way to share configuration between different projects?

build.gradle, gradle

Solution

The most reliable way to share configuration between builds is to code it up as a plugin class (i.e. a class implementing the `org.gradle.api.Plugin` interface), publish it as a Jar to a Maven or Ivy repository, and pull it in to consuming builds using a `buildscript` block. This will make sure that the plugin Jar gets cached like any other artifact dependency. How to go about this is explained in the Gradle User Guide.

Problem

We've got 3-5 different projects. I don't wanna copy/paste each time some parts of configuration from one project to another (like adding common maven repository). What's the best way to share common configuration across different projects? I've used `apply from: "http://path/to/common.build.gradle"` construction but our architector thinks that this is not the best solution because project build depends on external server that stores `common.build.gradle`. If you don't have connection to this server you can't build project. What do you think about it?

Original source