How To… Speed up Gradle build time (Gradle 빌드 속도)

2016. 1. 13. 11:46Programing/Android / Java

6.1. Enabling the Daemon

The Gradle Daemon is not enabled by default, but we do recommend always enabling it for developers’ machines (but leaving it disabled for continuous integration servers). There are several ways to enable the Daemon, but the most common one is to add the line

org.gradle.daemon=true

to the file «USER_HOME»/.gradle/gradle.properties, where «USER_HOME» is your home directory. That’s typically one of the following, depending on your platform:

  • C:\Users\<username> (Windows Vista & 7+)

  • /Users/<username> (Mac OS X)

  • /home/<username> (Linux)

If that file doesn’t exist, just create it using a text editor. You can find details of other ways to enable (and disable) the Daemon in the FAQ further down. That section also contains more detailed information on how the Daemon works.

Once you have globally enabled the Daemon in this way, all your builds will take advantage of the speed boost, regardless of the version of Gradle a particular build uses.

Continuous integration

At the moment, we recommend that you leave the Daemon disabled for continuous integration servers as using a fresh runtime for each build is more reliable since the runtime is completelyisolated from previously builds. Additionally, since the Daemon primarily acts to reduce build startup times, this isn't as critical in CI as it is on a developer's machine.

6.2. Stopping an existing Daemon

As mentioned, the Daemon is a background process. You needn’t worry about a build up of Gradle processes on your machine, though: every Daemon stops after 3 hours of inactivity. If you want to explicitly stop a Daemon process for any reason, just use the command gradle --stop.

This will terminate all Daemon processes that were started with the same version of Gradle used to execute the command. If you have the Java Development Kit (JDK) installed, you can easily verify that a Daemon has stopped by running the jps command. You’ll see any running Daemons listed with the name GradleDaemon.



>> 위 경우에 gradle.properties를 새로 생성해서 org.gradle.daemon=true만 추가해 주면 됩니다.

동일 프로젝트 빌드 시간 비교

<수정 전>

1번째 : 5분

2번째 : 5분

...동일

<수정 후>

1번째 : 6분

2번째 : 30초

....동일