Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with gradle wrapper, init script, multi project and best with idea

to sum up the components and environment:

  • multi-project, typically each gradle project is soley in a seperate git
    • you don't want to use submodules
  • gradle init scripts in a seperate config / super repository
  • using gradle wrapper
  • for the GUI guy: IntelliJ IDEa with Gradle integratiom -> help
  • allowed to use gradle idea -> guide

so,

Q: How to elegant marriage these components. How can I define an init script to be used in the wrapper of a single repository without affecting other repositories.

I know:

  • init scripts are typical in a "GRADLE_HOME" directory
  • init scripts can be defined per console via -I
    (yes, I read the documentation 😅 )

Problems found:

  • intelliJ doesn't allow to define the -I option in UI
  • anyone needs to checkout and update a seperate repository if you want to share between projects
  • the settings.gradle || gradle.properties file seems not to support any option either

Constraints: (while these are possible answers, they are neither elegant nor fault proof)

  • the desired solution should be applicable for SINGLE projects, and should not be globally applied to all projects on the same computer

Hidden Questions:

  • can I include global gradle settings from an URL so noone needs a clone of the meta-repo??
  • does an URL include do the same as an init script? Or what you can do with initScript what you can't in include?
like image 628
childno͡.de Avatar asked Feb 25 '16 16:02

childno͡.de


1 Answers

You can do the following:

  1. Create a custom gradle distribution with the common settings defined in the init script
  2. Configure your projects to use that distribution through the distributionUrl key in the gradle/wrapper/gradle-wrapper.properties
  3. Use regular gradle build from command line/usual import into intellij - it just works

By the way, there is a gradle plugin for simplifying custom gradle distribution construction

like image 187
denis.zhdanov Avatar answered Jan 03 '23 12:01

denis.zhdanov