首页 > 其他 > 详细

使用Gradle daemon加快Gradle开发速度

时间:2015-08-20 17:03:58      阅读:333      评论:0      收藏:0      [点我收藏+]

It takes a few seconds to finish the process, even there is only one file need to recompile. Because before gradle do any real building job, it has to do some initial work like loading JVM, prepare execution environment, loading Groovy classes etc.

When you frequently change and rebuild, the delay add up.

To resolve this problem, Gradle add a new feature "daemon". The daemon is just a Java application that runs in background thus cut the startup cost.

To start the daemon

 
gradle --daemon build
 

You can see the speedup when run with the daemon.

技术分享

To use the daemon you have to add --daemon option every time running the build.

To let gradle add this option automatically set the environment variable GRADLE_OPTS as this

 
set GRADLE_OPTS="-Dorg.gradle.daemon=true"
 

In my experience , this should always be set .

To make sure the daemon is running , if you are under Linux, check with this command

 
ps | grep gradle
 

In windows, check it in task manager

技术分享

It eat 74 MB of my memory. If you finish the development, its better to stop the daemon and free the memory. Its simple

 
gradle --stop
 

使用Gradle daemon加快Gradle开发速度

原文:http://my.oschina.net/httpssl/blog/495099

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!