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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With