How to configure multiple gradle.properties files in Gradle for multiple projects?

I have several projects using Gradle 2.4 as well.

I want to overwrite the org.gradle.java.home parameter in each project and try to add the gradle.properties file for each project and overwrite the parameter.

I installed the main Gradle project org.gradle.java.home=C:/Java/jdk1.6.0 and rewrote org.gradle.java.home=C:/Java/jdk1.7.0_45 in the subproject

But it doesn’t work as expected, and I get

incorrect original release: 1.7

error message.

Can someone give an idea on how to fix this problem?

+6
source share
1 answer

From my tests:

I created an empty root project without specifying which java to use and included two subprojects with different org.gradle.java.home and sourceCompatibility and targetCompatibility for each subproject and it works.

Project Structure :

 /build.gradle <-- root project (no sourceCompatibility or targetCompatibility here .. just blank) /settings.gradle <-- include the subprojects /gradle.properties <-- root gradle.properties (no org.gradle.java.home here) /sub1/build.gradle /sub1/gradle.properties /sub2/build.gradle /sub2/gradle.properties 

Root settings .gradle :

 include 'sub1' include 'sub2' 

Sub1 gradle.properties :

 org.gradle.java.home=/path/to/java8 

Sub1 build.gradle :

 sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 

Sub2 gradle.properties :

 org.gradle.java.home=/path/to/java7 

Sub2 build.gradle :

 sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 

So you can try this setting.

I assume because you are using your root project with java already defined (and not just a configuration point) - this could be a problem.

Also check these:

How do I tell Gradle to use a specific version of the JDK?

Gradle sourceCompatibility does not affect subprojects

+2
source

Source: https://habr.com/ru/post/988309/


All Articles