Skip to content

Commit c1bbc56

Browse files
committed
Normalize stub activity manifest and modernize Gradle updates
1 parent e4f2db5 commit c1bbc56

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

scripts/build-android-app.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,13 @@ seen = {"value": False}
392392
393393
def replace_activity(match):
394394
body = match.group(0)
395-
if "tools:node=" in body:
396-
body = re.sub(r'tools:node="[^"]*"', 'tools:node="replace"', body, count=1)
395+
body = re.sub(r'\s+tools:node="[^"]*"', '', body)
396+
if 'android:exported=' in body:
397+
body = re.sub(r'android:exported="[^"]*"', 'android:exported="true"', body, count=1)
397398
else:
398399
close = body.find('>')
399400
if close != -1:
400-
body = body[:close] + ' tools:node="replace"' + body[close:]
401+
body = body[:close] + ' android:exported="true"' + body[close:]
401402
if seen["value"]:
402403
return ''
403404
seen["value"] = True

scripts/update_android_ui_test_gradle.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,37 @@ def ensure_test_options(self) -> None:
231231
def remove_dex_options(self) -> None:
232232
self.content = re.sub(r"\s*dexOptions\s*\{[^{}]*\}\s*", "\n", self.content)
233233

234+
def convert_lint_options(self) -> None:
235+
block = self._find_block("lintOptions", parent="android")
236+
if not block:
237+
return
238+
block_text = self.content[block[0]:block[1]]
239+
start = block_text.find('{')
240+
end = block_text.rfind('}')
241+
if start == -1 or end == -1 or end <= start:
242+
self.content = (
243+
self.content[:block[0]]
244+
+ " lint {\n }\n"
245+
+ self.content[block[1]:]
246+
)
247+
return
248+
body = block_text[start + 1 : end]
249+
lines = []
250+
for line in body.splitlines():
251+
stripped = line.strip()
252+
if not stripped:
253+
lines.append("")
254+
else:
255+
lines.append(f" {stripped}")
256+
joined = "\n".join(lines)
257+
if joined:
258+
joined = joined + "\n"
259+
replacement = f" lint {{\n{joined} }}\n"
260+
self.content = self.content[:block[0]] + replacement + self.content[block[1]:]
261+
262+
def remove_jcenter(self) -> None:
263+
self.content = re.sub(r"^\s*jcenter\(\)\s*$\n?", "", self.content, flags=re.MULTILINE)
264+
234265
def ensure_dependencies(self) -> None:
235266
block = self._find_dependencies_block()
236267
if not block:
@@ -318,6 +349,8 @@ def apply(self) -> None:
318349
self.ensure_default_config()
319350
self.ensure_test_options()
320351
self.remove_dex_options()
352+
self.convert_lint_options()
353+
self.remove_jcenter()
321354
self.ensure_dependencies()
322355

323356
def summary(self) -> str:

0 commit comments

Comments
 (0)