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

user3496599

I have multiple projects and build using Gradle 2.4.

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

I have set the main gradle project org.gradle.java.home=C:/Java/jdk1.6.0 and overwrite in subproject as org.gradle.java.home=C:/Java/jdk1.7.0_45

But it is not working as expected and I'm getting

invalid source release: 1.7

error message.

Could someone give idea how to fix this issue?

Danail

From my tests:

I have created blank 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's settings.gradle:

include 'sub1'
include 'sub2'

Sub1's gradle.properties:

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

Sub1's build.gradle:

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

Sub2's gradle.properties:

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

Sub2's build.gradle:

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

So, you can try this setup.

I guess, because you are using your root project with already defined java (not just as configuration point) - this might be the problem.

Also check these ones:

How do I tell Gradle to use specific JDK version?

Gradle sourceCompatibility has no effect to subprojects

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to specify multiple binding files in gradle for ant xjc task

From Dev

Gradle: common resource dependency for multiple java projects

From Dev

How to use multiple build.gradle files?

From Dev

How to configure dagger + gradle

From Dev

How to compile multiple xsd files in Gradle JAXB/XJC?

From Dev

Gradle maven-publish how to use for multiple projects

From Dev

How Create Gradle sharedManifest for multiple projects?

From Dev

Android Studio Multiple dex files gradle error

From Dev

Multiple build.gradle files in Android Studio

From Dev

where to put sourceSets in multiple projects gradle

From Dev

Gradle multiple android apps

From Dev

How to include multiple Repositories in build.gradle?

From Dev

Gradle Multiple Maven Repo

From Dev

multiple maven repositories for gradle

From Dev

How do I concatenate multiple files in Gradle?

From Dev

Gradle: How to create multiple jar?

From Dev

Multiple maven repositories in Gradle

From Dev

MSBuild - How to build multiple files AND projects in parallel

From Dev

Storing Gradle configuration common to multiple projects

From Dev

Access restrictions in Eclipse Multiple Projects with Gradle

From Dev

Android gradle - how to search multiple respositories for gradle dependencies

From Dev

Gradle multiproject, multiple root projects and dependencies

From Dev

Reusing a spring test context across multiple Gradle projects

From Dev

Shipping multiple APKs on gradle

From Dev

How to share boilerplate Kotlin configuration across multiple Gradle projects?

From Dev

Gradle multiple versions OF GRADLE

From Dev

How to configure dagger + gradle

From Dev

How to build multiple APKs at once using Gradle?

From Dev

Sharing resources between multiple Eclipse WTP projects with Gradle

Related Related

  1. 1

    How to specify multiple binding files in gradle for ant xjc task

  2. 2

    Gradle: common resource dependency for multiple java projects

  3. 3

    How to use multiple build.gradle files?

  4. 4

    How to configure dagger + gradle

  5. 5

    How to compile multiple xsd files in Gradle JAXB/XJC?

  6. 6

    Gradle maven-publish how to use for multiple projects

  7. 7

    How Create Gradle sharedManifest for multiple projects?

  8. 8

    Android Studio Multiple dex files gradle error

  9. 9

    Multiple build.gradle files in Android Studio

  10. 10

    where to put sourceSets in multiple projects gradle

  11. 11

    Gradle multiple android apps

  12. 12

    How to include multiple Repositories in build.gradle?

  13. 13

    Gradle Multiple Maven Repo

  14. 14

    multiple maven repositories for gradle

  15. 15

    How do I concatenate multiple files in Gradle?

  16. 16

    Gradle: How to create multiple jar?

  17. 17

    Multiple maven repositories in Gradle

  18. 18

    MSBuild - How to build multiple files AND projects in parallel

  19. 19

    Storing Gradle configuration common to multiple projects

  20. 20

    Access restrictions in Eclipse Multiple Projects with Gradle

  21. 21

    Android gradle - how to search multiple respositories for gradle dependencies

  22. 22

    Gradle multiproject, multiple root projects and dependencies

  23. 23

    Reusing a spring test context across multiple Gradle projects

  24. 24

    Shipping multiple APKs on gradle

  25. 25

    How to share boilerplate Kotlin configuration across multiple Gradle projects?

  26. 26

    Gradle multiple versions OF GRADLE

  27. 27

    How to configure dagger + gradle

  28. 28

    How to build multiple APKs at once using Gradle?

  29. 29

    Sharing resources between multiple Eclipse WTP projects with Gradle

HotTag

Archive