I wrote below all the usual tricks.
Also in my machines the Windows versus Linux gradle battle is won by the Linux. However increasing the heap size, may help you get closer to your ubuntu compile time.
Increase the heap size
Starting from the Android Studio 2.0, all dex in the process runs in a single VM and that VM is also shared with the gradle. This requires more memory to accommodate all toghther.
By default, the heap size under Windows is 1GB. You have to increase the heap size. The more RAM you have the more you can use.
For an 8Gb RAM developper machine
i found that a 3GB heap size is best choice. For your 16GB machine you are free to experiment with a much more bigger heap size.
How to do it?
Add the line below to your gradle.properties:
org.gradle.jvmargs=-Xmx3072m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Parallelise build
(I saw you already did it, but i mention here for anybody else to read.)
If you have multiple modules in you project, allow gradle to build your project in parallel.
How to do it?
Add the line below to your gradle.properties:
org.gradle.parallel=true
Configure on demand
(I saw you already did it, but i mention here for anybody else to read.)
Gradle provides — configure-on-demand flag that will tell gradle to only build the components that it really needs.
Basically, it tells Gradle to configure modules that are only relevant to the requested tasks instead of configuring all of them.
This setting is usually relevant for multiple modules projects but notice libraries your project may also benefit for using this flag.
For example Google I/O app has two components Android (contains the source code related to the android application) and Server (contains code related to backend server). With default graddle settings they are both configured when compilling.
How to do it?
Add the line below to your gradle.properties:
org.gradle.configureondemand=true
... or access Preferences > Build, Execution, Deployment > Compiler and check configure on demand option.
Enable Gradle daemon
(I saw you already did it, but i mention here for anybody else to read.)
Gradle runs on the Java Virtual Machine (JVM) and uses several supporting libraries that require a non-trivial initialization time. As a result, it can sometimes seem a little slow to start. The solution to this problem is the Gradle Daemon: a long-lived background process that executes your builds much more quickly than would otherwise be the case.
You won’t be able to see the time difference in your first build, but build time will decrease in subsequent builds AFTER gradle daemon is initialised.
If you are using the gradle version 3.0 or above, the gradle daemon is by default enabled. If you are running on older versions it's not.
How to do it?
Add the line below to your gradle.properties:
org.gradle.daemon=true