Golang simple gradle cache server. Used to increase gradle build speed
Create sample directory structure
. /opt
├── data
│ ├── cache
│ ├── gradle-cache-server
│ └── config.json
Where
object | type | comment |
---|---|---|
cache | directory | directory for cache |
gradle-cache-server | file | server executable |
config.json | file | configuration file |
Server settings stored in file config.json
{
"path": "/opt/data/cache",
"port": 32555,
"scan": "1h",
"alive": "7d"
}
Where
property | type | comment |
---|---|---|
path | string | cache directory |
port | int | server port |
scan | string | cache clear: scan interval |
alive | string | cache clear: max time old file alive before delete |
Format is {number}{literal}
, where
literal | comment |
---|---|
s | second |
m | minute |
h | hour |
d | day |
w | week |
cd /opt/data
./gradle-cache-server
Note: server reads file config.json
from current workdir
In this sample gradle cache server started at the same computer, where gradle builds. But it can be started on a remote server.
Add next lines to settings.gradle
buildCache {
remote(HttpBuildCache) {
url = 'http://localhost:32555/'
push = true
}
}
For full list of configuration properties see documentation.
Note: server supports a cache subpath, like http://localhost:32555/team1/
From command line
gradle build --build-cache
Or from gradle.properties
file
org.gradle.caching=true
Prometheus metrics available at /metrics
endpoint on the same port.
Metrics
name | type | comment |
---|---|---|
cache_get | counter | Total number of requested items |
cache_put | counter | Total number of saved items |
cache_del | counter | Total number of deleted items |
name | comment |
---|---|
code | http status code (200 or 404) |
path0 | part#0 of url |
path1 | part#1 of url |
Request URL | path0 | path1 |
---|---|---|
/9af937214740e6369e0d9c47dbea521d | empty string | empty string |
/service/9af937214740e6369e0d9c47dbea521d | service | empty string |
/team/service/9af937214740e6369e0d9c47dbea521d | team | service |
/space/team/service/9af937214740e6369e0d9c47dbea521d | space | team |