1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from taskgraph
.util
.memoize
import memoize
13 'aar': ('.aar', '.pom', '-sources.jar'),
14 'jar': ('.jar', '.pom', '-sources.jar')
16 CHECKSUMS_EXTENSIONS
= ('.sha1', '.md5')
17 CURRENT_DIR
= os
.path
.dirname(os
.path
.realpath(__file__
))
18 PROJECT_DIR
= os
.path
.realpath(os
.path
.join(CURRENT_DIR
, '..', '..'))
19 ANDROID_COMPONENTS_DIR
= os
.path
.join(PROJECT_DIR
, "android-components")
23 build_config
= _read_build_config()
26 'path': project
['path'],
27 'shouldPublish': project
['publish']
28 } for (name
, project
) in build_config
['projects'].items()]
32 with
open(os
.path
.join(PROJECT_DIR
, "version.txt")) as fh
:
33 return fh
.read().strip()
36 def get_path(component
):
37 return _read_build_config()["projects"][component
]["path"]
40 def get_extensions(component
):
41 artifact_type
= _read_build_config()["projects"][component
].get("artifact-type", "aar")
42 if artifact_type
not in EXTENSIONS
:
44 "For '{}', 'artifact-type' must be one of {}".format(
45 component
, repr(EXTENSIONS
.keys())
50 extension
+ checksum_extension
51 for extension
in EXTENSIONS
[artifact_type
]
52 for checksum_extension
in ('',) + CHECKSUMS_EXTENSIONS
57 def _read_build_config():
58 with
open(os
.path
.join(ANDROID_COMPONENTS_DIR
, '.buildconfig.yml'), 'rb') as f
:
59 return yaml
.safe_load(f
)