-
Notifications
You must be signed in to change notification settings - Fork 4
/
generate_external_protos.py
executable file
·51 lines (39 loc) · 1.7 KB
/
generate_external_protos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
# Used to automatically pull in external dependencies defined in Maven into Pants' 3rdparty BUILD
import logging
import os
import sys
from textwrap import dedent
from pom_file import PomFile
from pom_utils import PomUtils
from target_template import Target
logger = logging.getLogger(__name__)
class ExternalProtosBuildGenerator(object):
def __init__(self):
pass
def generate(self):
handler = PomUtils.external_protos_content_handler()
pom_file = PomFile('parents/external-protos/pom.xml')
jar_dep = Target.jar.format(org='com.squareup.protos',
name='all-protos',
rev=handler.properties['external-protos.all-protos-latest'],
symbols=pom_file.properties,
file_name=pom_file.path)
template = dedent("""\
# Automatically generated by {script}
# The jar version is used the majority of BUILD files in external-protos as the latest version of all-protos to extract .proto sources from
# Seeded from the external-protos.all-protos-latest property defined in external/protos/pom.xml
{target}
target(name='test')
""")
return template.format(script=os.path.basename(sys.argv[0]),
target=Target.jar_library.format(name='latest-all-protos',
jars=[jar_dep],))
def main():
"""Test driver that spits out parents/external-protos/BUILD.gen contents.
Run from ~/Development/java
"""
print(ExternalProtosBuildGenerator().generate())
if __name__ == "__main__":
PomUtils.parse_common_args(sys.argv[1:])
main()