2020-06-03 19:47:01 +00:00
|
|
|
# Parser for android/gradle.properties file.
|
|
|
|
# Returns an attrset with keys and values from it.
|
|
|
|
{ lib }:
|
|
|
|
|
|
|
|
gradlePropsFile:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) head last filter listToAttrs splitString nameValuePair hasPrefix readFile;
|
|
|
|
|
|
|
|
# Read lines
|
|
|
|
lines = splitString "\n" (readFile gradlePropsFile);
|
|
|
|
|
|
|
|
isKeyValueLine = line: line != "" && !hasPrefix "#" line;
|
2022-05-26 09:11:34 +00:00
|
|
|
cleanup = filter isKeyValueLine;
|
2020-06-03 19:47:01 +00:00
|
|
|
extractKeyValues = line:
|
|
|
|
let flag = splitString "=" line;
|
|
|
|
in nameValuePair (head flag) (last flag);
|
|
|
|
parseAttrs = lines: listToAttrs (map extractKeyValues lines);
|
|
|
|
in
|
|
|
|
parseAttrs (cleanup lines)
|