user2536273
user2536273

Reputation: 69

Multiple Project Gradle Config

I have 2 projects structured in

--app (Project 1)
    --build.gradle (Application Project Level - Need 5.x ) 
--services (Project 2)<br>
    --build.gradle (Services Project Level - Cann't support more than 2.x) <br>
--build.gradle (Top Level) 
--gradlew 
--settings.gradle


Can I configure my "services project" to use a specific gradle version only ?
Currently I have constraint that restrict me for updating my gradle version.

Previously it was configured to use 2.x (gradle wrapper) and it was working fine and building both app and service project.
I have to update the version to 4.x but there is a constraint that will not accept for services project to build higher that 2.x. Can it both separated and build?


Can we have 2 projects configured to use 2 different versions for gradle and 1 gradle wrapper?

Upvotes: 1

Views: 268

Answers (1)

tryman
tryman

Reputation: 3293

The way to go in this case would be the Gradle wrapper which is local to your project only. As you'll see in the link from the Gradle docs:

The Wrapper is a script that invokes a declared version of Gradle, downloading it beforehand if necessary.

Which is exactly what you want.

  • To have it readily configured for your coworkers, check in the wrapper to your version control system, namely the two files gradle-wrapper.properties and gradle-wrapper.jar in the directory YourProject\gradle\wrapper\.
  • If until now you executed Gradle using the command line: gradle (arguments), now to use the wrapper you'll execute ./gradlew (arguments) with the same arguments inside your project folder.
  • If you use an IDE, when you import the project there will be an option to use the gradle wrapper. Choose that.

The Gradle docs in the mentioned links have a good documentation on how to set up the Gradle wrapper, use it and upgrade it to a later version.

It goes without saying but you don't need to change anything in your buildscript (build.gradle file). The wrapper is not a different application, it just makes sure that the correct Gradle version is invoked.

Upvotes: 2

Related Questions