码迷,mamicode.com
首页 > 其他好文 > 详细

使用Gradle daemon加快Gradle开发速度

时间:2015-08-20 17:05:35      阅读:475      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!