Is your feature request related to a problem? Please describe.
Large projects with hundreds of subprojects take minutes on import/refresh.
Describe the solution you'd like
This is a general problem of Gradle's configuration phase. Traditionally, all (sub)projects are configured in sequence. Hence, the more projects you have, the longer the configuration takes.
To improve this situation, Gradle is working on parallel configuration of projects for some time already. The feature that should finally solve it is now called Isolated Projects. The main change is that projects are no longer allowed to access each others state during configuration. With this, the order in which projects are configured no longer influences the result.
To use the feature, you first need to make sure your own build configuration and the third-party plugins you use do no longer utilise cross-project configuration constructs. Then you can turn it on in the project's gradle.properties via:
org.gradle.unsafe.isolated-projects=true
This works in my projects when building from command line or importing in recent IntelliJ versions. Importing in VS Code fails though, because the configuration code added via init script to build the IDE Model is using APIs that access cross-project state.
You get these errors (can be reproduced with any project):
- Initialization script '...': line 8: Project ':' cannot access 'Project.apply' functionality on subprojects via 'allprojects'
- Plugin class 'com.microsoft.gradle.GradlePlugin': Project ':' cannot access 'Project.buildscript' functionality on child projects
- Plugin class 'com.microsoft.gradle.GradlePlugin': Project ':' cannot access 'Project.configurations' functionality on child projects
I did some initial analysis and I think the two things that need to be changed is:
- No longer use
allprojects { ... } in the init script here.
Instead, use the new isolated API gradle.lifecycle.beforeProject { ... }
- No longer access child projects through their parent here to later access their
buildscript and configurations containers inside GradleProjectModelBuilder. How exactly this should be done would need to be researched. But it must be possible to avoid this.
Describe alternatives you've considered
No alternatives.
Is your feature request related to a problem? Please describe.
Large projects with hundreds of subprojects take minutes on import/refresh.
Describe the solution you'd like
This is a general problem of Gradle's configuration phase. Traditionally, all (sub)projects are configured in sequence. Hence, the more projects you have, the longer the configuration takes.
To improve this situation, Gradle is working on parallel configuration of projects for some time already. The feature that should finally solve it is now called Isolated Projects. The main change is that projects are no longer allowed to access each others state during configuration. With this, the order in which projects are configured no longer influences the result.
To use the feature, you first need to make sure your own build configuration and the third-party plugins you use do no longer utilise cross-project configuration constructs. Then you can turn it on in the project's
gradle.propertiesvia:This works in my projects when building from command line or importing in recent IntelliJ versions. Importing in VS Code fails though, because the configuration code added via init script to build the IDE Model is using APIs that access cross-project state.
You get these errors (can be reproduced with any project):
I did some initial analysis and I think the two things that need to be changed is:
allprojects { ... }in the init script here.Instead, use the new isolated API
gradle.lifecycle.beforeProject { ... }buildscriptandconfigurationscontainers insideGradleProjectModelBuilder. How exactly this should be done would need to be researched. But it must be possible to avoid this.Describe alternatives you've considered
No alternatives.