1616 <SentryiOSArtifactsDestination >$(SentryArtifactsDestination)iOS/Sentry.xcframework~/</SentryiOSArtifactsDestination >
1717 <SentrymacOSArtifactsDestination >$(SentryArtifactsDestination)macOS/Sentry/</SentrymacOSArtifactsDestination >
1818 <!-- Android -->
19+ <SentryNativeNdkCache >$(RepoRoot)modules/sentry-native-ndk/</SentryNativeNdkCache >
1920 <SentryAndroidRoot >$(RepoRoot)modules/sentry-java/</SentryAndroidRoot >
2021 <SentryAndroidArtifactsDestination >$(SentryArtifactsDestination)Android/Sentry~/</SentryAndroidArtifactsDestination >
2122 <!-- Native -->
@@ -228,8 +229,10 @@ Expected to exist:
228229 </Target >
229230
230231 <!-- Build the Android SDK: dotnet msbuild /t:BuildAndroidSDK src/Sentry.Unity -->
231- <Target Name =" BuildAndroidSDK" Condition =" '$(MSBuildProjectName)' == 'Sentry.Unity'
232- And !Exists('$(SentryAndroidArtifactsDestination)')" BeforeTargets =" BeforeBuild" >
232+ <Target Name =" BuildAndroidSDK"
233+ DependsOnTargets =" DownloadCLI"
234+ Condition =" '$(MSBuildProjectName)' == 'Sentry.Unity' And !Exists('$(SentryAndroidArtifactsDestination)')"
235+ BeforeTargets =" BeforeBuild" >
233236 <Error Condition =" !Exists('$(SentryAndroidRoot)')" Text =" Couldn't find the Android root at $(SentryAndroidRoot)." />
234237 <Message Importance =" High" Text =" Building Sentry Android SDK." />
235238
@@ -243,6 +246,48 @@ Expected to exist:
243246 <Copy SourceFiles =" @(AndroidSdkArtifacts)" DestinationFiles =" @(AndroidSdkArtifacts->'$(SentryAndroidArtifactsDestination)%(RecursiveDir)%(Filename)%(Extension)')" />
244247 <Exec WorkingDirectory =" $(SentryAndroidRoot)" Command =" cp sentry/build/libs/sentry*.jar $(SentryAndroidArtifactsDestination)sentry.jar" />
245248
249+ <Message Importance =" High" Text =" Reading the sentry-native-ndk version from the 'Config.kt' file." />
250+
251+ <PropertyGroup >
252+ <PropertiesContent >$([System.IO.File]::ReadAllText("$(RepoRoot)modules/sentry-java/buildSrc/src/main/java/Config.kt"))</PropertiesContent >
253+ <NativeVersion >$([System.Text.RegularExpressions.Regex]::Match($(PropertiesContent), 'sentryNativeNdk\s*=\s*"[^"]+:([^"]+)"').Groups[1].Value)</NativeVersion >
254+ </PropertyGroup >
255+
256+ <!-- Clean cache if version does not exist to get rid of old versions -->
257+ <RemoveDir
258+ Condition =" !Exists('$(SentryNativeNdkCache)sentry-native-ndk-$(NativeVersion).zip')"
259+ Directories =" $(SentryNativeNdkCache)" />
260+
261+ <!-- Create cache directory -->
262+ <MakeDir Condition =" !Exists('$(SentryNativeNdkCache)')" Directories =" $(SentryNativeNdkCache)" />
263+
264+ <Message Importance =" High" Text =" Downloading sentry-native-ndk version '$(NativeVersion)'." />
265+
266+ <!-- Download prebuilt sentry-native-ndk -->
267+ <Exec
268+ Condition =" !Exists('$(SentryNativeNdkCache)sentry-native-ndk-$(NativeVersion).zip')"
269+ Command =" curl -L https://github.com/getsentry/sentry-native/releases/download/$(NativeVersion)/sentry-native-ndk-$(NativeVersion).zip -o $(SentryNativeNdkCache)sentry-native-ndk-$(NativeVersion).zip" />
270+
271+ <Exec
272+ Condition =" !Exists('$(SentryNativeNdkCache)sentry-native-ndk-$(NativeVersion)')"
273+ Command =" unzip -o $(SentryNativeNdkCache)sentry-native-ndk-$(NativeVersion).zip -d $(SentryNativeNdkCache)" />
274+
275+ <Copy SourceFiles =" $(SentryNativeNdkCache)sentry-native-ndk-$(NativeVersion)/sentry-native-ndk-release.aar" DestinationFiles =" $(SentryAndroidArtifactsDestination)sentry-native-ndk-release.aar" />
276+
277+ <Error Condition =" !Exists('$(SentryAndroidArtifactsDestination)')" Text =" Failed to build the Android SDK." />
278+ </Target >
279+
280+ <!-- Build the NDK: dotnet msbuild /t:DownloadNDK src/Sentry.Unity -->
281+ <Target Name =" DownloadNDK" >
282+ <Message Importance =" High" Text =" Downloading Sentry NDK SDK." />
283+
284+ <PropertyGroup >
285+ <PropertiesContent >$([System.IO.File]::ReadAllText("$(RepoRoot)modules/sentry-java/buildSrc/src/main/java/Config.kt"))</PropertiesContent >
286+ <NativeVersion >$([System.Text.RegularExpressions.Regex]::Match($(PropertiesContent), 'sentryNativeNdk\s*=\s*"[^"]+:([^"]+)"').Groups[1].Value)</NativeVersion >
287+ </PropertyGroup >
288+
289+ <Message Importance =" High" Text =" Downloading up the NDK SDK version '$(NativeVersion)'." />
290+
246291 <Error Condition =" !Exists('$(SentryAndroidArtifactsDestination)')" Text =" Failed to build the Android SDK." />
247292 </Target >
248293
0 commit comments