Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions tools/google_maven_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ def _download_from_google_maven(self, request_path: str, artifact_path: Path) ->

class MirrorHandler(BaseHTTPRequestHandler):
mirror_index: MavenMirrorIndex
EMPTY_JAR_BYTES = (
b"PK\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
)

def do_GET(self) -> None: # noqa: N802
self._serve(send_body=True)
Expand Down Expand Up @@ -499,8 +502,11 @@ def _send_bytes(
@staticmethod
def _synthetic_response(request_path: str) -> tuple[str, bytes] | None:
marker_prefix = "com/android/application/com.android.application.gradle.plugin/"
if request_path.startswith(marker_prefix) and request_path.endswith(".pom"):
version = request_path.removeprefix(marker_prefix).split("/", 1)[0]
if not request_path.startswith(marker_prefix):
return None

version = request_path.removeprefix(marker_prefix).split("/", 1)[0]
if request_path.endswith(".pom"):
pom = f"""<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand All @@ -520,6 +526,9 @@ def _synthetic_response(request_path: str) -> tuple[str, bytes] | None:
""".encode("utf-8")
return "application/xml; charset=utf-8", pom

if request_path.endswith(".jar"):
return "application/java-archive", MirrorHandler.EMPTY_JAR_BYTES

return None


Expand Down
Loading