|
| 1 | +"""Script to update the androidx repo with the released axt versions.""" |
| 2 | + |
| 3 | +from collections.abc import Sequence |
| 4 | +import fileinput |
| 5 | +import os |
| 6 | + |
| 7 | +from absl import app |
| 8 | + |
| 9 | +from tools.release import release_versions |
| 10 | + |
| 11 | + |
| 12 | +def main(argv: Sequence[str]) -> None: |
| 13 | + if len(argv) > 1: |
| 14 | + raise app.UsageError('Too many command-line arguments.') |
| 15 | + |
| 16 | + _edit_gradle_versions() |
| 17 | + _edit_docs_versions() |
| 18 | + _output_import_command() |
| 19 | + |
| 20 | + |
| 21 | +def _edit_gradle_versions(): |
| 22 | + """Edit the gradle versions in the androidx repo.""" |
| 23 | + androidx_home = os.environ['ANDROIDX_HOME'] |
| 24 | + gradle_versions_path = os.path.join( |
| 25 | + androidx_home, 'frameworks/support/gradle/libs.versions.toml' |
| 26 | + ) |
| 27 | + print('Modifying ' + gradle_versions_path) |
| 28 | + print('') |
| 29 | + with fileinput.input(files=[gradle_versions_path], inplace=True) as file: |
| 30 | + for line in file: |
| 31 | + if line.startswith('espresso = "'): |
| 32 | + print( |
| 33 | + 'espresso = "{Espresso}"'.format( |
| 34 | + **release_versions.RELEASED_VERSIONS_DICT |
| 35 | + ) |
| 36 | + ) |
| 37 | + elif line.startswith('espressoDevice = "'): |
| 38 | + print( |
| 39 | + 'espressoDevice = "{Espresso Device}"'.format( |
| 40 | + **release_versions.RELEASED_VERSIONS_DICT |
| 41 | + ) |
| 42 | + ) |
| 43 | + elif line.startswith('androidxTestRunner = "'): |
| 44 | + print( |
| 45 | + 'androidxTestRunner = "{Runner}"'.format( |
| 46 | + **release_versions.RELEASED_VERSIONS_DICT |
| 47 | + ) |
| 48 | + ) |
| 49 | + elif line.startswith('androidxTestRules = "'): |
| 50 | + print( |
| 51 | + 'androidxTestRules = "{Rules}"'.format( |
| 52 | + **release_versions.RELEASED_VERSIONS_DICT |
| 53 | + ) |
| 54 | + ) |
| 55 | + elif line.startswith('androidxTestMonitor = "'): |
| 56 | + print( |
| 57 | + 'androidxTestMonitor = "{Monitor}"'.format( |
| 58 | + **release_versions.RELEASED_VERSIONS_DICT |
| 59 | + ) |
| 60 | + ) |
| 61 | + elif line.startswith('androidxTestCore = "'): |
| 62 | + print( |
| 63 | + 'androidxTestCore = "{Core}"'.format( |
| 64 | + **release_versions.RELEASED_VERSIONS_DICT |
| 65 | + ) |
| 66 | + ) |
| 67 | + elif line.startswith('androidxTestExtJunit = "'): |
| 68 | + print( |
| 69 | + 'androidxTestExtJunit = "{JUnit Extensions}"'.format( |
| 70 | + **release_versions.RELEASED_VERSIONS_DICT |
| 71 | + ) |
| 72 | + ) |
| 73 | + elif line.startswith('androidxTestExtTruth = "'): |
| 74 | + print( |
| 75 | + 'androidxTestExtTruth = "{Truth Extensions}"'.format( |
| 76 | + **release_versions.RELEASED_VERSIONS_DICT |
| 77 | + ) |
| 78 | + ) |
| 79 | + else: |
| 80 | + print(line.rstrip()) |
| 81 | + |
| 82 | + |
| 83 | +def _edit_docs_versions(): |
| 84 | + """Edit the axt versions used in docs-public build in androidx repo.""" |
| 85 | + androidx_home = os.environ['ANDROIDX_HOME'] |
| 86 | + docs_version_path = os.path.join( |
| 87 | + androidx_home, 'frameworks/support/docs-public/build.gradle' |
| 88 | + ) |
| 89 | + print('Modifying ' + docs_version_path) |
| 90 | + print('') |
| 91 | + |
| 92 | + output = True |
| 93 | + with fileinput.input(files=[docs_version_path], inplace=True) as file: |
| 94 | + for line in file: |
| 95 | + if 'docsWithoutApiSince("androidx.test' in line: |
| 96 | + if output: |
| 97 | + print( |
| 98 | + """ docsWithoutApiSince("androidx.test:core:{Core}") |
| 99 | + docsWithoutApiSince("androidx.test:core-ktx:{Core}") |
| 100 | + docsWithoutApiSince("androidx.test:monitor:{Monitor}") |
| 101 | + docsWithoutApiSince("androidx.test:rules:{Rules}") |
| 102 | + docsWithoutApiSince("androidx.test:runner:{Runner}") |
| 103 | + docsWithoutApiSince("androidx.test.espresso:espresso-accessibility:{Espresso}") |
| 104 | + docsWithoutApiSince("androidx.test.espresso:espresso-contrib:{Espresso}") |
| 105 | + docsWithoutApiSince("androidx.test.espresso:espresso-core:{Espresso}") |
| 106 | + docsWithoutApiSince("androidx.test.espresso:espresso-device:{Espresso Device}") |
| 107 | + docsWithoutApiSince("androidx.test.espresso:espresso-idling-resource:{Espresso}") |
| 108 | + docsWithoutApiSince("androidx.test.espresso:espresso-intents:{Espresso}") |
| 109 | + docsWithoutApiSince("androidx.test.espresso:espresso-remote:{Espresso}") |
| 110 | + docsWithoutApiSince("androidx.test.espresso:espresso-web:{Espresso}") |
| 111 | + docsWithoutApiSince("androidx.test.espresso.idling:idling-concurrent:{Espresso}") |
| 112 | + docsWithoutApiSince("androidx.test.espresso.idling:idling-net:{Espresso}") |
| 113 | + docsWithoutApiSince("androidx.test.ext:junit:{JUnit Extensions}") |
| 114 | + docsWithoutApiSince("androidx.test.ext:junit-ktx:{JUnit Extensions}") |
| 115 | + docsWithoutApiSince("androidx.test.ext:truth:{Truth Extensions}") |
| 116 | + docsWithoutApiSince("androidx.test.services:storage:{Services}")""".format( |
| 117 | + **release_versions.RELEASED_VERSIONS_DICT |
| 118 | + ) |
| 119 | + ) |
| 120 | + output = False |
| 121 | + else: |
| 122 | + print(line.rstrip()) |
| 123 | + |
| 124 | + |
| 125 | +def _output_import_command(): |
| 126 | + """Output the command to download the maven artifacts in androidx repo.""" |
| 127 | + print('Run this command:') |
| 128 | + print( |
| 129 | + """ |
| 130 | + development/importMaven/importMaven.sh \\ |
| 131 | + androidx.test.espresso:espresso-accessibility:{Espresso} \\ |
| 132 | + androidx.test.espresso:espresso-device:{Espresso Device} \\ |
| 133 | + androidx.test.espresso:espresso-remote:{Espresso} \\ |
| 134 | + androidx.test.espresso.idling:idling-concurrent:{Espresso} \\ |
| 135 | + androidx.test.espresso.idling:idling-net:{Espresso} \\ |
| 136 | + androidx.test.espresso:espresso-contrib:{Espresso} \\ |
| 137 | + androidx.test.ext:truth:{Truth Extensions} \\ |
| 138 | + androidx.test.ext:junit-ktx:{JUnit Extensions} \\ |
| 139 | + androidx.test:monitor:{Monitor} \\ |
| 140 | + androidx.test:rules:{Rules} \\ |
| 141 | + androidx.test:runner:{Runner} \\ |
| 142 | + androidx.test.espresso:espresso-intents:{Espresso} \\ |
| 143 | + androidx.test:core-ktx:{Core}""".format( |
| 144 | + **release_versions.RELEASED_VERSIONS_DICT |
| 145 | + ) |
| 146 | + ) |
| 147 | + |
| 148 | + |
| 149 | +if __name__ == '__main__': |
| 150 | + app.run(main) |
0 commit comments