How to optimize gradle build performance regarding build duration and RAM usage?

后端 未结 9 1391

I am currently switching from ant to gradle for my multi module web application and at the moment it seems that the current version of Gradle (M9) might be running up agains

9条回答
  •  渐次进展
    2020-12-02 11:53

    I just found a very nice way to handle this problem. No need for custom gradle wrapper or GRADLE_OPTIONS.

    compileJava {
        options.fork = true  // Fork your compilation into a child process
        options.forkOptions.setMemoryMaximumSize("4g") // Set maximum memory to 4g
    }
    

    Run Gradle with the --info option to see where it's going to use your parameter for max memory size.

    gradle build --info
    

提交回复
热议问题