diff --git a/eng/cake/dotnet.cake b/eng/cake/dotnet.cake index 7a3bd74f5dd6..210670ff5804 100644 --- a/eng/cake/dotnet.cake +++ b/eng/cake/dotnet.cake @@ -95,8 +95,29 @@ Task("dotnet-buildtasks") throw exception; }); +Task("android-aar") + .Does(() => + { + var root = "./src/Core/AndroidNative/"; + + var gradlew = root + "gradlew"; + if (IsRunningOnWindows()) + gradlew += ".bat"; + + var exitCode = StartProcess( + MakeAbsolute((FilePath)gradlew), + new ProcessSettings + { + Arguments = $"createAar --rerun-tasks", + WorkingDirectory = root + }); + if (exitCode != 0) + throw new Exception("Gradle failed to build maui.aar: " + exitCode); + }); + Task("dotnet-build") .IsDependentOn("dotnet") + .IsDependentOn("android-aar") .Description("Build the solutions") .Does(() => { @@ -270,6 +291,7 @@ Task("dotnet-test") }); Task("dotnet-pack-maui") + .IsDependentOn("android-aar") .WithCriteria(RunPackTarget()) .Does(() => { diff --git a/eng/pipelines/common/provision.yml b/eng/pipelines/common/provision.yml index 8d46fc859985..a977db31c942 100644 --- a/eng/pipelines/common/provision.yml +++ b/eng/pipelines/common/provision.yml @@ -53,6 +53,7 @@ steps: # Setup JDK Paths - bash: | echo "##vso[task.setvariable variable=JI_JAVA_HOME]$(JAVA_HOME_11_X64)" + echo "##vso[task.setvariable variable=JAVA_HOME]$(JAVA_HOME_11_X64)" displayName: 'Setup JDK Paths' # Configure VS Mac for Xcode - bash: | @@ -121,6 +122,39 @@ steps: env: PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }} + - pwsh: | + if ($env:JAVA_HOME_11_X64) { + $env:JAVA_HOME = $env:JAVA_HOME_11_X64 + } else { + $path = (Get-ChildItem $env:ProgramFiles\Microsoft\jdk-11.*\bin\java.exe) | Select-Object -First 1 + if ($path -and (Test-Path $path)) { + $env:JAVA_HOME = $path.Directory.Parent.FullName + } + } + if ($env:JAVA_HOME) { + echo "##vso[task.setvariable variable=JAVA_HOME]$env:JAVA_HOME" + echo "JAVA_HOME set to '$env:JAVA_HOME'" + } else { + echo "Unable to set JAVA_HOME" + } + displayName: 'Setup JDK Paths' + + - pwsh: | + if ($env:ANDROID_SDK_ROOT) { + echo "ANDROID_SDK_ROOT already set to '$env:ANDROID_SDK_ROOT'" + } else { + if ((Test-Path "${env:ProgramFiles(x86)}\Android\android-sdk")) { + $env:ANDROID_SDK_ROOT = "${env:ProgramFiles(x86)}\Android\android-sdk" + } + if ($env:ANDROID_SDK_ROOT) { + echo "##vso[task.setvariable variable=ANDROID_SDK_ROOT]$env:ANDROID_SDK_ROOT" + echo "ANDROID_SDK_ROOT set to '$env:ANDROID_SDK_ROOT'" + } else { + echo "Unable to set ANDROID_SDK_ROOT" + } + } + displayName: 'Setup ANDROID_SDK_ROOT Paths' + # Prepare Both - task: UseDotNet@2 # https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer?view=azure-devops displayName: 'Use .NET SDK 7'