• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2019 The Flutter Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import os
8import sys
9import json
10
11THIS_DIR = os.path.abspath(os.path.dirname(__file__))
12
13# The template for the POM file.
14POM_FILE_CONTENT = '''
15<?xml version="1.0" encoding="UTF-8"?>
16<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"
17    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
18  <modelVersion>4.0.0</modelVersion>
19  <groupId>io.flutter</groupId>
20  <artifactId>{0}</artifactId>
21  <version>{1}</version>
22  <packaging>jar</packaging>
23  <dependencies>
24    {2}
25  </dependencies>
26</project>
27'''
28
29POM_DEPENDENCY = '''
30    <dependency>
31      <groupId>{0}</groupId>
32      <artifactId>{1}</artifactId>
33      <version>{2}</version>
34      <scope>compile</scope>
35    </dependency>
36'''
37
38def main():
39  with open (os.path.join(THIS_DIR, 'files.json')) as f:
40    dependencies = json.load(f)
41
42  parser = argparse.ArgumentParser(description='Generate the POM file for the engine artifacts')
43  parser.add_argument('--engine-artifact-id', type=str, required=True,
44                      help='The artifact id. e.g. android_arm_release')
45  parser.add_argument('--engine-version', type=str, required=True,
46                      help='The engine commit hash')
47  parser.add_argument('--destination', type=str, required=True,
48                      help='The destination directory absolute path')
49  parser.add_argument('--include-embedding-dependencies', type=bool,
50                      help='Include the dependencies for the embedding')
51
52  args = parser.parse_args()
53  engine_artifact_id = args.engine_artifact_id
54  engine_version = args.engine_version
55  artifact_version = '1.0.0-' + engine_version
56  out_file_name = '%s-%s.pom' % (engine_artifact_id, artifact_version)
57
58  pom_dependencies = ''
59  if args.include_embedding_dependencies:
60    for dependency in dependencies:
61      group_id, artifact_id, version = dependency['maven_dependency'].split(':')
62      pom_dependencies += POM_DEPENDENCY.format(group_id, artifact_id, version)
63
64  # Write the POM file.
65  with open(os.path.join(args.destination, out_file_name), 'w') as f:
66    f.write(POM_FILE_CONTENT.format(engine_artifact_id, artifact_version, pom_dependencies))
67
68if __name__ == '__main__':
69  sys.exit(main())
70