#!/usr/bin/python

"""
Copyright 2018 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import argparse
import subprocess

NAME_HELP = '''
  The name of the artifact you want to add to the prebuilts folder.
  E.g. android.arch.work:work-runtime-ktx:1.0.0-alpha07
'''


def main():
    """Parses the command line arguments, and executes the gradle script
    which downloads the maven artifacts.
    """
    parser = argparse.ArgumentParser(
        description='Helps download maven artifacts to prebuilts.')
    parser.add_argument('-n', '--name', help=NAME_HELP,
                        required=True, dest='name')
    parse_result = parser.parse_args()
    artifact_name = parse_result.name
    command = './gradlew --build-file build.gradle.kts -PartifactName=%s' % (
        artifact_name)
    process = subprocess.Popen(command,
                               shell=True,
                               stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    stdout, stderr = process.communicate()

    if stderr is not None:
        lines = stderr.split('\n')
        for line in lines:
            print line

    if stdout is not None:
        lines = stdout.split('\n')
        for line in lines:
            print line


if __name__ == '__main__':
    main()

Add the helper script to import packages from Maven.
Add the helper script to import packages from Maven.

Test: Tested the script locally.

Change-Id: I0b3bf330d340a30f14ddbe5704668e9666577d8d
