Mercurial > public > develkit
diff init20.gradle @ 200:8aab0c2c1259
add helpers for memory checks
author | smith@nwoca.org |
---|---|
date | Fri, 14 Aug 2015 16:13:24 +0100 |
parents | 5bc8264bb979 |
children | e721a977726b e90ce1d50d85 |
line wrap: on
line diff
--- a/init20.gradle Wed Aug 05 13:31:24 2015 +0100 +++ b/init20.gradle Fri Aug 14 16:13:24 2015 +0100 @@ -534,6 +534,21 @@ } catch (e) { } } + + void requireMemory(int megabytes) { + if (systemFreeMemory > 0 && systemFreeMemory < megabytes) { + throw new GradleException("insufficent free OS memory for this build (available: ${systemFreeMemory}m, required: ${megabytes}m)") + } + } + /** + * Returns maximum memory available upto the value specified. + */ + int maxMemory(int megabytes) { + if (systemFreeMemory) { + [systemFreeMemory,megabytes].min() + } else { megabytes } + + } }