param( [Parameter(Mandatory = $true)][string]$HBuilderXHome, [Parameter(Mandatory = $true)][string]$SdkJar ) $ErrorActionPreference = 'Stop' # Compile the generated UTS and the original native bridge against real SDKs. # First export App resources using HBuilderX. SdkJar is classes.jar extracted # from the official dy-pay-sdk-tob 1.1.0.9 AAR, not a mock or reflection shim. $projectDir = Split-Path -Parent $PSScriptRoot $runtimeDir = Join-Path $HBuilderXHome 'plugins/uniapp-runextension' $compilerDir = Join-Path $runtimeDir 'kotlinc' $generated = Join-Path $projectDir 'unpackage/resources/uni_modules/tb-douyin-pay/utssdk/app-android/src/index.kt' $native = Join-Path $projectDir 'uni_modules/tb-douyin-pay/utssdk/app-android/TbDouyinPayNative.kt' foreach ($required in @($SdkJar, $generated, $native, (Join-Path $compilerDir 'lib/kotlin-compiler.jar'))) { if (!(Test-Path -LiteralPath $required)) { throw "Missing dependency or source: $required" } } $taskClasspath = ((Get-ChildItem -LiteralPath (Join-Path $runtimeDir 'lib') -Filter '*.jar').FullName + @((Resolve-Path -LiteralPath $SdkJar).Path)) -join ';' $resultDir = New-Item -ItemType Directory -Path (Join-Path ([IO.Path]::GetTempPath()) ('tb-douyin-kotlin-' + [guid]::NewGuid().ToString('N'))) $resultJar = Join-Path $resultDir.FullName 'tb-douyin-pay.jar' & java -cp (Join-Path $compilerDir 'lib/*') org.jetbrains.kotlin.cli.jvm.K2JVMCompiler ` -kotlin-home $compilerDir $generated $native -classpath $taskClasspath -d $resultJar if ($LASTEXITCODE -ne 0) { throw "Kotlin compilation failed: $LASTEXITCODE" } Write-Output "Kotlin compilation passed: $resultJar" Write-Output 'This check does not build/sign an APK or execute a payment.'