13THIS_DIR = os.path.abspath(os.path.dirname(__file__))
16POM_FILE_CONTENT =
'''<?xml version="1.0" encoding="UTF-8"?>
17<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
18 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
19 <modelVersion>4.0.0</modelVersion>
21 <artifactId>{0}</artifactId>
22 <version>{1}</version>
23 <packaging>jar</packaging>
32 <groupId>{0}</groupId>
33 <artifactId>{1}</artifactId>
34 <version>{2}</version>
35 <scope>compile</scope>
39MAVEN_METADATA_CONTENT = '''
40<metadata xmlns=
"http://maven.apache.org/METADATA/1.1.0" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://maven.apache.org/METADATA/1.1.0 http://maven.apache.org/xsd/metadata-1.1.0.xsd" modelVersion=
"1.1.0">
42 <artifactId>{0}</artifactId>
43 <version>{1}</version>
46 <version>{1}</version>
49 <timestamp>{2}</timestamp>
50 <buildNumber>0</buildNumber>
54 <extension>jar</extension>
58 <extension>pom</extension>
68 return str(s,
'utf-8')
if isinstance(s, (bytes, bytearray))
else s
72 with open(os.path.join(THIS_DIR,
'files.json'))
as f:
73 dependencies = json.load(f)
75 parser = argparse.ArgumentParser(description=
'Generate the POM file for the engine artifacts')
77 '--engine-artifact-id',
80 help=
'The artifact id. e.g. android_arm_release'
82 parser.add_argument(
'--engine-version', type=utf8, required=
True, help=
'The engine commit hash')
84 '--destination', type=utf8, required=
True, help=
'The destination directory absolute path'
87 '--include-embedding-dependencies',
89 help=
'Include the dependencies for the embedding'
92 args = parser.parse_args()
93 engine_artifact_id = args.engine_artifact_id
94 engine_version = args.engine_version
95 artifact_version =
'1.0.0-' + engine_version
96 out_file_name =
'%s.pom' % engine_artifact_id
99 if args.include_embedding_dependencies:
100 for dependency
in dependencies:
101 if not dependency[
'provides']:
104 group_id, artifact_id, version = dependency[
'maven_dependency'].split(
':')
105 pom_dependencies += POM_DEPENDENCY.format(group_id, artifact_id, version)
108 with open(os.path.join(args.destination, out_file_name),
'w')
as f:
109 f.write(POM_FILE_CONTENT.format(engine_artifact_id, artifact_version, pom_dependencies))
112 with open(os.path.join(args.destination,
'%s.maven-metadata.xml' % engine_artifact_id),
'w')
as f:
113 timestamp = datetime.datetime.utcnow().strftime(
"%Y%m%d.%H%M%S")
114 f.write(MAVEN_METADATA_CONTENT.format(engine_artifact_id, artifact_version, timestamp))
117if __name__ ==
'__main__':