$ErrorActionPreference = "Stop" $appRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path $repoRoot = Split-Path -Parent (Split-Path -Parent $appRoot) $dstPluginRoot = Join-Path $appRoot "nativeplugins\native-fast-printer" $manifestPath = Join-Path $appRoot "src\manifest.json" Write-Host "[1/4] Validate source plugin files..." $sourceAarItem = Get-ChildItem -LiteralPath $repoRoot -Recurse -File -Filter "native_fast_printer-release.aar" | Where-Object { $_.FullName -notlike "*\nativeplugins\native-fast-printer\android\*" } | Sort-Object LastWriteTime -Descending | Select-Object -First 1 if ($null -eq $sourceAarItem) { throw "AAR not found under repository root: $repoRoot" } $srcPluginRoot = Split-Path -Parent (Split-Path -Parent $sourceAarItem.FullName) $srcAar = $sourceAarItem.FullName Write-Host "Selected SRC AAR: $srcAar" $srcPkg = Join-Path $srcPluginRoot "package.json" $srcReadme = Join-Path $srcPluginRoot "README.md" if (!(Test-Path -LiteralPath $srcPkg)) { throw "package.json not found: $srcPkg" } if (!(Test-Path -LiteralPath $srcReadme)) { throw "README.md not found: $srcReadme" } Write-Host "[2/4] Sync files into uniapp nativeplugins..." if (Test-Path -LiteralPath $dstPluginRoot) { Remove-Item -LiteralPath $dstPluginRoot -Recurse -Force } New-Item -ItemType Directory -Path (Join-Path $dstPluginRoot "android") -Force | Out-Null Copy-Item -LiteralPath $srcPkg -Destination (Join-Path $dstPluginRoot "package.json") Copy-Item -LiteralPath $srcReadme -Destination (Join-Path $dstPluginRoot "README.md") Copy-Item -LiteralPath $srcAar -Destination (Join-Path $dstPluginRoot "android\native_fast_printer-release.aar") Write-Host "[3/4] Validate manifest plugin declaration..." if (!(Test-Path -LiteralPath $manifestPath)) { throw "manifest not found: $manifestPath" } $manifestContent = Get-Content -LiteralPath $manifestPath -Raw if ($manifestContent -notmatch '"native-fast-printer"\s*:\s*\{') { throw "manifest.json missing app-plus.nativePlugins.native-fast-printer declaration" } Write-Host "[4/4] Print summary..." $srcInfo = Get-Item -LiteralPath $srcAar $dstAar = Join-Path $dstPluginRoot "android\native_fast_printer-release.aar" $dstInfo = Get-Item -LiteralPath $dstAar Write-Host "SRC AAR: $($srcInfo.Length) bytes, $($srcInfo.LastWriteTime.ToString("s"))" Write-Host "DST AAR: $($dstInfo.Length) bytes, $($dstInfo.LastWriteTime.ToString("s"))" Write-Host "Done: native-fast-printer synced. Next: build custom base in HBuilderX."