diff --git a/AGENTS.md b/AGENTS.md index a75184cc95..6f83c00e9e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,10 +26,10 @@ Run commands from this repository's root, not from `msal/`, `common/`, or the parent android-complete checkout. The commands below use PowerShell on Windows; on macOS/Linux use `./gradlew` with equivalent JDK, SDK, and feed configuration. -1. Use **JDK 17**, as configured in the +1. Use **JDK 21**, as configured for upgraded-branch validation in the [MSAL PR pipeline](azure-pipelines/pull-request-validation/pr-msal.yml). Set `JAVA_HOME` for the current shell. Use the checked-in wrapper - (Gradle 8.11.1), not a globally installed Gradle; check `.\gradlew.bat --version`. + (Gradle 9.3.1 / AGP 9.1.1), not a globally installed Gradle; check `.\gradlew.bat --version`. Java 8 source/bytecode targets are not the required Gradle runtime. 2. Initialize the pinned Common submodule in a fresh checkout: @@ -40,9 +40,11 @@ on macOS/Linux use `./gradlew` with equivalent JDK, SDK, and feed configuration. Inspect existing submodule work before updating an established checkout. Do not use `--remote` or change the submodule pin merely to make a build pass. -3. Install Android SDK platform 36 and the build tools required by +3. Install Android SDK platform 37 and the build tools required by [version configuration](gradle/versions.gradle). Configure `ANDROID_HOME` - or an untracked root `local.properties` containing `sdk.dir`. + or an untracked root `local.properties` containing `sdk.dir`. The upgrade retains + targetSdk 36 and all existing minSdk values. Java/Kotlin bytecode remains at 1.8; + the library retains dev's Kotlin language/API 1.9 compatibility pin. 4. Obtain Packaging Read access to the NewAndroid feed configured in [settings](settings.gradle) and [the root build](build.gradle). Provision `ENV_VSTS_MVN_CRED_USERNAME` and `ENV_VSTS_MVN_CRED_ACCESSTOKEN` @@ -94,8 +96,46 @@ These match the build/report/lint tasks and SDK used by the [PR pipeline](azure-pipelines/pull-request-validation/pr-msal.yml). SpotBugs requires assembled outputs; its task name comes from [Common's template](common/azure-pipelines/templates/steps/spotbugs.yml). +Do not count `spotbugsLocalDebug NO-SOURCE` as a pass. Keep the assembly hooks +lazy with `tasks.configureEach`: `tasks.whenTaskAdded` eagerly realizes SpotBugs +6.5.8 tasks before AGP 9 registers their javac tasks, leaving analysis inputs +empty. Verify the SpotBugs task executes with nonempty compiled-class inputs; +inspect its findings or an explicitly enabled report, not just the build status. +XML reports are enabled for each SpotBugs variant under +`msal/build/reports/spotbugs/`; confirm the report has analyzed classes. +The [SpotBugs filter](config/spotbugs/exclude.xml) baselines reviewed findings by +class, method, and detector to preserve existing API and recovery behavior. +These deferred ownership, nullability, locking, and hardening findings are not +proof of safety. Keep new exclusions equally scoped; do not disable detectors +globally or copy another repository's baseline wholesale. +The analyzer also emits missing Android/JSON class diagnostics that were present +before the upgrade. A passing findings gate does not resolve that separate +analysis-classpath completeness limitation. The coverage task depends on `testLocalDebugUnitTest` and fails if execution data is missing. Do not publish a missing-data report as successful coverage. +The custom local/dist reports include AGP 9 built-in Kotlin outputs as well as +javac outputs. Inspect the XML for Kotlin classes, not just a successful task. + +### Distribution and publication metadata + +Source builds do not validate published Common compatibility. Separately run: + +```powershell +.\gradlew.bat :msal:assembleDistRelease :msal:generatePomFileForMsalPublication "-PdistCommonVersion=" +.\gradlew.bat :msal:jacocoDistTestReport :msal:assembleDistDebugAndroidTest "-PdistCommonVersion=" "-PdistCommon4jVersion=" -PcodeCoverageEnabled=true +``` + +These commands do not publish. Verify the generated POM has `aar` packaging and +the intended Common dependency. DIST configuration/assembly must also work in +a checkout without Common source; never move or overwrite a working submodule +to test this while another build is using it. The standalone golden examples +have their own legacy wrappers and consume published MSAL, not this source build; +they are not evidence of SDK source validation. The root sample is +`:testapps:testapp:assembleLocalDebug` (also test `assembleLocalRelease` for R8). +`:package-inspector:assembleDebug` is independent of Common. The optional +`:pop-benchmarker:assembleDebug` currently cannot select between Common's +local/dist variants; report that separately rather than selecting a flavor or +raising its minSdk as part of this upgrade. ### Network integration and UI-less E2E diff --git a/azure-pipelines/pull-request-validation/pr-msal.yml b/azure-pipelines/pull-request-validation/pr-msal.yml index 763d491c2a..87cf75c2c5 100644 --- a/azure-pipelines/pull-request-validation/pr-msal.yml +++ b/azure-pipelines/pull-request-validation/pr-msal.yml @@ -52,9 +52,9 @@ stages: displayName: 'Set VSTS Fields in Environment' - template: azure-pipelines/templates/steps/automation-cert.yml@common - task: JavaToolInstaller@0 - displayName: Use Java 17 + displayName: Use Java 21 inputs: - versionSpec: '17' + versionSpec: '21' jdkArchitectureOption: x64 jdkSourceOption: PreInstalled - task: CodeQL3000Init@0 @@ -65,7 +65,7 @@ stages: tasks: clean msal:assembleLocal publishJUnitResults: false testResultsFiles: '**/build/test-results/TEST-*.xml' - jdkVersion: $(BuildParameters.jdkVersion) + jdkVersion: 1.21 jdkArchitecture: $(BuildParameters.jdkArchitecture) sqGradlePluginVersion: 2.0.1 - task: CodeQL3000Finalize@0 @@ -74,7 +74,7 @@ stages: inputs: tasks: msal:jacocoTestReport -PcodeCoverageEnabled=true -ProbolectricSdkVersion=${{variables.robolectricSdkVersion}} -PmockApiUrl=$(MOCK_API_URL) -PnativeAuthConfigString=$(NATIVE_AUTH_CONFIG_STRING) javaHomeSelection: $(BuildParameters.javaHomeSelection) - jdkVersion: 1.17 + jdkVersion: 1.21 - template: azure-pipelines/templates/steps/collect-changed-files.yml@common parameters: outputDir: $(Build.SourcesDirectory)/msal/build/reports/jacoco/jacocoTestReport @@ -149,6 +149,7 @@ stages: - template: azure-pipelines/templates/steps/spotbugs.yml@common parameters: project: msal + javaVersion: "1.21" - job: lint displayName: Lint (PR) cancelTimeoutInMinutes: 1 @@ -166,7 +167,7 @@ stages: inputs: tasks: clean msal:lintLocalDebug publishJUnitResults: false - jdkVersion: 1.17 + jdkVersion: 1.21 - template: azure-pipelines/code-coverage/compare-code-coverage.yml@common parameters: commonRepoAlias: common diff --git a/azure-pipelines/pull-request-validation/pr-msalautomationapp.yml b/azure-pipelines/pull-request-validation/pr-msalautomationapp.yml index f446c14c44..5ca6763776 100644 --- a/azure-pipelines/pull-request-validation/pr-msalautomationapp.yml +++ b/azure-pipelines/pull-request-validation/pr-msalautomationapp.yml @@ -8,7 +8,7 @@ name: $(date:yyyyMMdd)$(rev:.r) trigger: none variables: - name: BuildParameters.jdkVersion - value: 1.17 + value: 1.21 - name: BuildParameters.jdkArchitecture value: x64 @@ -40,9 +40,9 @@ stages: displayName: 'Set VSTS Fields in Environment' - template: azure-pipelines/templates/steps/automation-cert.yml@common - task: JavaToolInstaller@0 - displayName: Use Java 17 + displayName: Use Java 21 inputs: - versionSpec: '17' + versionSpec: '21' jdkArchitectureOption: x64 jdkSourceOption: PreInstalled - task: Gradle@2 diff --git a/common b/common index c91ba7c6de..46711a62c7 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit c91ba7c6de223952455c6d255701c1472c813ed6 +Subproject commit 46711a62c7a9fda14cbae91d60f37c0dc5e6edbf diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml new file mode 100644 index 0000000000..87545bfc7d --- /dev/null +++ b/config/spotbugs/exclude.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index 9da7fae4d1..7e4732d32f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,13 @@ ariaTenantTokenTest="1e8435186fa849b28b1a402fb5074ff1-0b91a9ec-efad-440c-b92c-ac android.useAndroidX=true android.enableJetifier=true +# AGP 9 opt-out (STOPGAP, removed in AGP 10): restores the legacy DSL + Variant API +# (libraryVariants/applicationVariants) still used by common/build.gradle (output naming +# + per-variant Javadoc). Root gradle.properties governs the whole multi-project build, +# so this must live here (the copy in common/gradle.properties is not read as a subproject). +# Track migration to the androidComponents API before AGP 10. +android.newDsl=false + # https://office.visualstudio.com/Outlook%20Mobile/_wiki/wikis/Outlook-Mobile.wiki/3780/Android-Studio-Gradle-Performance-tips-and-tricks org.gradle.parallel=true org.gradle.daemon=true diff --git a/gradle/versions.gradle b/gradle/versions.gradle index d6f1b3e3d7..ffba8c39b0 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -3,13 +3,17 @@ ext { // SDK minSdkVersion = 24 - targetSdkVersion = 35 - compileSdkVersion = 36 - buildToolsVersion = "36.0.0" + targetSdkVersion = 36 + compileSdkVersion = 37 + buildToolsVersion = "37.0.0" // Plugins - gradleVersion = '8.10.0' - kotlinVersion = '2.0.21' + // NOTE: 'gradleVersion' is the AGP (Android Gradle Plugin) version, NOT the Gradle + // wrapper version (that lives in gradle/wrapper/gradle-wrapper.properties = 9.3.1). + gradleVersion = '9.1.1' + // Kotlin 1.8.x has no Gradle 9 support (removed SelfResolvingDependency); AGP 9 + // built-in Kotlin also needs KGP >= 2.2.10. Matches the upgraded common submodule. + kotlinVersion = '2.2.21' spotBugsGradlePluginVersion = '4.7.1' jupiterApiVersion = '5.6.0' @@ -42,7 +46,7 @@ ext { powerMockVersion = "2.0.9" runnerVersion = "1.2.0" rulesVersion = "1.2.0" - robolectricVersion = "4.14" + robolectricVersion = "4.16.1" uiAutomatorVersion = "2.2.0" daggerVersion = "2.31.2" daggerCompilerVersion = "2.31.2" @@ -67,7 +71,7 @@ ext { yubikitAndroidVersion = "2.5.0" yubikitPivVersion = "2.5.0" powerliftAndroidVersion="1.0.3" - kotlinXCoroutinesVersion = "1.6.4" + kotlinXCoroutinesVersion = "1.9.0" mockkVersion = "1.11.0" mockitoKotlinVersion = "4.1.0" androidxAnnotationVersion = "1.4.0" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7046bb0561..6cda1d726c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip diff --git a/msal/build.gradle b/msal/build.gradle index 564e7bd4f3..366d8f874a 100644 --- a/msal/build.gradle +++ b/msal/build.gradle @@ -1,10 +1,12 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion + plugins { - id 'com.microsoft.identity.buildsystem' version '0.2.5' + id 'com.microsoft.identity.buildsystem' version '0.3.0' id 'com.android.library' id 'pmd' id 'checkstyle' id 'maven-publish' - id 'kotlin-android' id 'jacoco' // Test retries @@ -16,10 +18,25 @@ apply from: 'versioning/version_tasks.gradle' group = 'com.microsoft.identity.client' +// Built-in Kotlin (AGP 9): replaces the android { kotlinOptions { } } block that the +// removed 'kotlin-android' plugin previously provided. +kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_1_8 + // Preserve dev's published Kotlin metadata compatibility. + languageVersion = KotlinVersion.KOTLIN_1_9 + apiVersion = KotlinVersion.KOTLIN_1_9 + } +} + buildSystem { desugar = false } +tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach { + reports.maybeCreate("xml").required.set(true) +} + def enableCodeCoverage = false if (project.hasProperty("codeCoverageEnabled")) { @@ -73,7 +90,7 @@ def registerJacocoXmlReport = { String taskName, String variant -> ] def kotlinClasses = fileTree( - dir: "$buildDir/tmp/kotlin-classes/${variant}", + dir: "$buildDir/intermediates/built_in_kotlinc/${variant}/compile${variantCap}Kotlin/classes", excludes: fileFilter ) @@ -130,7 +147,7 @@ android { targetSdkVersion rootProject.ext.targetSdkVersion versionCode getAppVersionCode() versionName getAppVersionName() - project.archivesBaseName = "msal" + project.base.archivesName = "msal" project.version = android.defaultConfig.versionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -138,11 +155,8 @@ android { buildConfig = true } - kotlinOptions { - jvmTarget = "1.8" - // Pinned to 1.9 so published metadata stays readable by consumers still on Kotlin 1.8. - languageVersion = "1.9" - apiVersion = "1.9" + publishing { + singleVariant("distRelease") {} } buildTypes { @@ -210,7 +224,7 @@ android { libraryVariants.all { variant -> variant.outputs.all { - def fileName = "${archivesBaseName}-${version}.aar" + def fileName = "${project.base.archivesName.get()}-${version}.aar" outputFileName = fileName } } @@ -279,7 +293,7 @@ if (project.hasProperty("distCommonVersion")) { // Used for testfixtures def common4jVersion = "1.0.+" if (project.hasProperty("distCommon4jVersion")) { - distCommon4jVersion = project.distCommon4jVersion + common4jVersion = project.distCommon4jVersion } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$rootProject.ext.kotlinVersion" @@ -307,8 +321,13 @@ dependencies { testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoCoreVersion" testImplementation ("org.robolectric:robolectric:$rootProject.ext.robolectricVersion") testImplementation "androidx.test:core:$rootProject.ext.androidxTestCoreVersion" - testLocalImplementation project(':testutils') - testLocalImplementation project(':LabApiUtilities') + // The common-source projects are only on the build when the `common` submodule is checked out + // (see settings.gradle). Guard these `local`-flavor project deps so :msal still configures for + // DIST/publish builds that consume the PUBLISHED common artifacts instead. + if (findProject(':testutils') != null) { + testLocalImplementation project(':testutils') + testLocalImplementation project(':LabApiUtilities') + } testDistImplementation("com.microsoft.identity:testutils:0.0+") { exclude module: 'common' exclude group: 'com.microsoft.identity', module: 'LabApiUtilities' @@ -334,15 +353,19 @@ dependencies { // instrumented tests; the org.gradle.test-retry plugin only covers JVM/Robolectric unit tests). // transitive = false keeps only the rule's classes and avoids dragging testutils' whole // transitive graph onto the androidTest classpath. - androidTestLocalImplementation(project(':testutils')) { - transitive = false + if (findProject(':testutils') != null) { + androidTestLocalImplementation(project(':testutils')) { + transitive = false + } } androidTestDistImplementation("com.microsoft.identity:testutils:0.0+") { transitive = false } // 'local' flavor dependencies - localApi(project(":common")) { - transitive = true + if (findProject(':common') != null) { + localApi(project(":common")) { + transitive = true + } } snapshotApi(group: 'com.microsoft.identity', name: 'common', version: commonVersion, changing: true) @@ -351,7 +374,9 @@ dependencies { transitive = true } - testLocalImplementation(testFixtures(project(":common4j"))) + if (findProject(':common4j') != null) { + testLocalImplementation(testFixtures(project(":common4j"))) + } testDistImplementation(testFixtures("com.microsoft.identity:common4j:${common4jVersion}")) implementation "io.opentelemetry:opentelemetry-api:$rootProject.ext.openTelemetryVersion" @@ -402,10 +427,10 @@ afterEvaluate { // to include the version number. tasks.named("assembleDistRelease").configure { if (project.findProperty("renameOutput")?.toString()?.toBoolean() == true) { - def buildFile = file("$buildDir/outputs/aar/${archivesBaseName}-dist-release.aar") + def buildFile = file("$buildDir/outputs/aar/${project.base.archivesName.get()}-dist-release.aar") println "Build file $buildFile" doLast { - def renamedFile = file("$buildDir/outputs/aar/${archivesBaseName}-${version}.aar") + def renamedFile = file("$buildDir/outputs/aar/${project.base.archivesName.get()}-${version}.aar") println "Renaming build file $buildFile to '$renamedFile'" if (!buildFile.renameTo(renamedFile)) { println "Rename failed!" @@ -416,7 +441,7 @@ afterEvaluate { publishing { publications { msal(MavenPublication) { - from components.findByName('distRelease') + from components.distRelease groupId 'com.microsoft.identity.client' artifactId 'msal' //Edit the 'version' here for VSTS RC build @@ -464,7 +489,8 @@ afterEvaluate { } } -tasks.whenTaskAdded { task -> +// Eager task hooks realize SpotBugs before AGP has registered its javac tasks. +tasks.configureEach { task -> if (task.name.contains('assemble')) { task.dependsOn 'pmd' } diff --git a/msal/src/androidTest/AndroidManifest.xml b/msal/src/androidTest/AndroidManifest.xml index 578aa6b3fa..b50e52428d 100644 --- a/msal/src/androidTest/AndroidManifest.xml +++ b/msal/src/androidTest/AndroidManifest.xml @@ -4,10 +4,6 @@ android:versionCode="1" android:versionName="1.0"> - - diff --git a/msal/src/androidTest/java/com/microsoft/identity/client/PublicClientConfigurationTest.java b/msal/src/androidTest/java/com/microsoft/identity/client/PublicClientConfigurationTest.java index ab4d9d333c..1d7b287dbb 100644 --- a/msal/src/androidTest/java/com/microsoft/identity/client/PublicClientConfigurationTest.java +++ b/msal/src/androidTest/java/com/microsoft/identity/client/PublicClientConfigurationTest.java @@ -66,7 +66,10 @@ public class PublicClientConfigurationTest { @Before public void setUp() { mContext = InstrumentationRegistry.getContext().getApplicationContext(); - mDefaultConfig = loadConfig(R.raw.msal_default_config); + // msal_default_config is a MAIN source-set resource, so it lives in the module R + // (com.microsoft.identity.msal.R), not the androidTest R (…msal.test.R) imported above. + // Under AGP's non-transitive R classes the test R only exposes androidTest resources. + mDefaultConfig = loadConfig(com.microsoft.identity.msal.R.raw.msal_default_config); } @After diff --git a/msal/src/main/java/com/microsoft/identity/client/helper/BrokerHelperActivity.java b/msal/src/main/java/com/microsoft/identity/client/helper/BrokerHelperActivity.java index fe3bc9c736..baa5674b05 100644 --- a/msal/src/main/java/com/microsoft/identity/client/helper/BrokerHelperActivity.java +++ b/msal/src/main/java/com/microsoft/identity/client/helper/BrokerHelperActivity.java @@ -21,7 +21,7 @@ */ public class BrokerHelperActivity extends Activity { - private final String MANIFEST_TEMPLATE = "\n" + + private static final String MANIFEST_TEMPLATE = "\n" + " \n" + " \n" + " \n" + diff --git a/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java b/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java index 5b4a4ea00e..a48c4f19c6 100644 --- a/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java +++ b/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java @@ -608,7 +608,7 @@ public static SignInStartCommandParameters createSignInStartCommandParameters( * Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.SignInStartCommand}] of Native Auth using continuation token * @param configuration PCA configuration * @param tokenCache token cache for storing results - * @param continuationToken continuation token + * @param continuationToken non-null continuation token * @param username email address of the user * @param correlationId correlation ID to use in the API request, taken from the previous API response in the flow * @param scopes scopes requested during sign in flow @@ -619,7 +619,7 @@ public static SignInStartCommandParameters createSignInStartCommandParameters( public static SignInWithContinuationTokenCommandParameters createSignInWithContinuationTokenCommandParameters( @NonNull final NativeAuthPublicClientApplicationConfiguration configuration, @NonNull final OAuth2TokenCache tokenCache, - @Nullable final String continuationToken, + @NonNull final String continuationToken, @Nullable final String username, @NonNull final String correlationId, final List scopes, diff --git a/msal/src/test/java/com/microsoft/identity/client/e2e/tests/network/nativeauth/SignInEmailPasswordTest.kt b/msal/src/test/java/com/microsoft/identity/client/e2e/tests/network/nativeauth/SignInEmailPasswordTest.kt index 17f5191312..e4ad2d0c2b 100644 --- a/msal/src/test/java/com/microsoft/identity/client/e2e/tests/network/nativeauth/SignInEmailPasswordTest.kt +++ b/msal/src/test/java/com/microsoft/identity/client/e2e/tests/network/nativeauth/SignInEmailPasswordTest.kt @@ -34,7 +34,6 @@ import com.microsoft.identity.nativeauth.statemachine.results.GetAccountResult import com.microsoft.identity.nativeauth.statemachine.results.SignInResult import com.microsoft.identity.nativeauth.statemachine.results.SignOutResult import kotlinx.coroutines.runBlocking -import org.checkerframework.checker.units.qual.s import org.junit.Assert import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue diff --git a/msalautomationapp/build.gradle b/msalautomationapp/build.gradle index 3727ae39cf..07dece9b44 100644 --- a/msalautomationapp/build.gradle +++ b/msalautomationapp/build.gradle @@ -1,5 +1,6 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' def msalVersion = "5.10.0" @@ -13,6 +14,14 @@ if (project.hasProperty("localFlights")) { copyOfLocalFlights = localFlights } +// Built-in Kotlin (AGP 9): replaces the android { kotlinOptions { } } block that the +// removed 'kotlin-android' plugin previously provided. +kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_1_8 + } +} + android { namespace "com.microsoft.identity.client.msal.automationapp" packagingOptions { @@ -26,9 +35,8 @@ android { } buildFeatures { buildConfig = true - } - kotlinOptions { - jvmTarget = "1.8" + // AGP 9 defaults resValues to off; the local/dist flavors define resValue(...) so opt in. + resValues = true } final String BROKER_HOST = "BrokerHost" final String BROKER_MICROSOFT_AUTHENTICATOR = "BrokerMicrosoftAuthenticator" diff --git a/settings.gradle b/settings.gradle index 0b365512cf..97271f20ce 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,25 +9,57 @@ pluginManagement { name "vsts-maven-new-android" url "https://identitydivision.pkgs.visualstudio.com/_packaging/NewAndroid/maven/v1" credentials { - username System.getenv("ENV_VSTS_MVN_CRED_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_CRED_USERNAME") : settings.ext.find("vstsUsername") - password System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") : settings.ext.find("vstsMavenAccessToken") + username System.getenv("ENV_VSTS_MVN_CRED_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_CRED_USERNAME") : providers.gradleProperty("vstsUsername").getOrNull() + password System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") : providers.gradleProperty("vstsMavenAccessToken").getOrNull() } } } } -include ':msal', ':common', ':keyvault', ':labapi', ':testutils', ':pop-benchmarker', - ':package-inspector', ':msalautomationapp', ':uiautomationutilities', ':common4j', - ':LabApiUtilities' +// Common-source dependencies are guarded below so DIST builds also work without the submodule. +include ':msal', ':package-inspector' -project(':common').projectDir = new File('common/common') -project(':keyvault').projectDir = new File('common/keyvault') -project(':labapi').projectDir = new File('common/labapi') -project(':testutils').projectDir = new File('common/testutils') -project(':uiautomationutilities').projectDir = new File('common/uiautomationutilities') -project(':common4j').projectDir = new File('common/common4j') -project(':LabApiUtilities').projectDir = new File('common/LabApiUtilities') +// The projects below live in the `common` git submodule (checked out at msal/common). +// They are only needed when building common FROM SOURCE (the `local` product flavor, plus +// the automation/benchmark apps). The `dist`/`snapshot` flavors — including the 1ES weekly +// DIST publish — instead consume the PUBLISHED com.microsoft.identity:common / :common4j +// artifacts (via -PdistCommonVersion), and those pipelines often run WITHOUT the submodule +// checked out. +// +// Gradle 8 silently tolerated `include`-ing a project whose directory didn't exist; Gradle 9 +// fails hard ("Configuring project ':X' without an existing directory is not allowed"). So we +// only include the common-source projects when the submodule is actually present on disk. +if (new File(settingsDir, 'common/common').exists()) { + include ':common', ':keyvault', ':labapi', ':testutils', + ':uiautomationutilities', ':common4j', ':LabApiUtilities' + // These apps consume common modules FROM SOURCE (project(':common'), project(':LabApiUtilities'), + // project(':uiautomationutilities'), project(':common4j')) unconditionally, so they can only + // configure when the submodule is present. DIST/publish builds don't build these apps. + include ':pop-benchmarker', ':msalautomationapp' + + project(':common').projectDir = new File('common/common') + project(':keyvault').projectDir = new File('common/keyvault') + project(':labapi').projectDir = new File('common/labapi') + project(':testutils').projectDir = new File('common/testutils') + project(':uiautomationutilities').projectDir = new File('common/uiautomationutilities') + project(':common4j').projectDir = new File('common/common4j') + project(':LabApiUtilities').projectDir = new File('common/LabApiUtilities') +} else { + logger.lifecycle("[settings.gradle] 'common' submodule not checked out — skipping " + + "common-source project includes. DIST/SNAPSHOT builds use the published " + + "com.microsoft.identity:common artifacts; for a source (local-flavor) build run: " + + "git submodule update --init --recursive") +} // test apps -include ':testapps:sample' +// Gradle 9 rejects `include` of a project whose directory doesn't exist (Gradle 8 tolerated it). +// Rather than dropping these includes, guard each one so it configures only when its directory is +// present on disk. This keeps ':testapps:automationapp' / ':testapps:sample' in the build for any +// context that provides those project directories, while a plain checkout (which only has +// 'testapp') still configures under Gradle 9 instead of failing hard. include ':testapps:testapp' -include ':testapps:automationapp' +if (new File(settingsDir, 'testapps/automationapp').exists()) { + include ':testapps:automationapp' +} +if (new File(settingsDir, 'testapps/sample').exists()) { + include ':testapps:sample' +} diff --git a/testapps/testapp/build.gradle b/testapps/testapp/build.gradle index 1dc78a8130..ff586d97d5 100644 --- a/testapps/testapp/build.gradle +++ b/testapps/testapp/build.gradle @@ -23,9 +23,9 @@ * // THE SOFTWARE. */ -apply plugin: 'com.android.application' +import org.jetbrains.kotlin.gradle.dsl.JvmTarget -apply plugin: 'kotlin-android' +apply plugin: 'com.android.application' def msalVersion = "8.3.2" @@ -39,6 +39,14 @@ if(project.hasProperty('otelAriaToken')) { otelAriaToken = project.otelAriaToken; } +// Built-in Kotlin (AGP 9): replaces the android { kotlinOptions { } } block that the +// removed 'kotlin-android' plugin previously provided. +kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_1_8 + } +} + android { namespace "com.microsoft.identity.client.testapp" // Bumping up to Java Version 8 due to the addition of YubiKit SDK, @@ -78,15 +86,14 @@ android { release { signingConfig signingConfigs.release minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } - kotlinOptions { - jvmTarget = "1.8" - } buildFeatures { viewBinding true buildConfig true + // AGP 9 defaults resValues to off; the local/dist flavors define resValue(...) so opt in. + resValues true } lintOptions { abortOnError false @@ -115,6 +122,9 @@ dependencies { implementation "androidx.constraintlayout:constraintlayout:$rootProject.ext.constraintLayoutVersion" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlinXCoroutinesVersion" implementation "androidx.appcompat:appcompat:$rootProject.ext.appCompatVersion" + // Edge-to-edge inset handling in StartActivity uses WindowInsetsCompat.Type (androidx.core >= 1.5.0); + // appcompat 1.1.0 only pulls core 1.1.0 transitively, so pin core explicitly. + implementation "androidx.core:core:$rootProject.ext.androidxCoreVersion" implementation "androidx.legacy:legacy-support-v4:$rootProject.ext.legacySupportV4Version" implementation "com.google.android.material:material:$rootProject.ext.materialVersion" implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlinVersion}" diff --git a/testapps/testapp/proguard-rules.pro b/testapps/testapp/proguard-rules.pro index 0d0a880acc..4dd34ca7b5 100644 --- a/testapps/testapp/proguard-rules.pro +++ b/testapps/testapp/proguard-rules.pro @@ -30,3 +30,5 @@ -dontwarn org.bouncycastle.openssl.PEMKeyPair -dontwarn org.bouncycastle.openssl.PEMParser -dontwarn org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter +# Common excludes these compile-time annotations; WebKit's marker is not needed at runtime. +-dontwarn org.jspecify.annotations.NullMarked diff --git a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailAttributeSignUpFragment.kt b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailAttributeSignUpFragment.kt index 951607dc9c..1bb8978917 100644 --- a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailAttributeSignUpFragment.kt +++ b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailAttributeSignUpFragment.kt @@ -114,8 +114,8 @@ class EmailAttributeSignUpFragment : Fragment() { var password: CharArray? = null if (binding.passwordText.length() > 0) { password = CharArray(binding.passwordText.length()) + (binding.passwordText.text as? android.text.GetChars)?.getChars(0, binding.passwordText.length(), password, 0) } - binding.passwordText.text?.getChars(0, binding.passwordText.length(), password, 0) val attributes = UserAttributes.Builder() diff --git a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailPasswordSignInSignUpFragment.kt b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailPasswordSignInSignUpFragment.kt index f6f02492c6..60626875de 100644 --- a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailPasswordSignInSignUpFragment.kt +++ b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/EmailPasswordSignInSignUpFragment.kt @@ -116,7 +116,7 @@ class EmailPasswordSignInSignUpFragment : Fragment() { try { val email = binding.emailText.text.toString() val password = CharArray(binding.passwordText.length()); - binding.passwordText.text?.getChars(0, binding.passwordText.length(), password, 0); + (binding.passwordText.text as? android.text.GetChars)?.getChars(0, binding.passwordText.length(), password, 0); val actionResult = authClient.signIn( username = email, @@ -167,7 +167,7 @@ class EmailPasswordSignInSignUpFragment : Fragment() { try { val email = binding.emailText.text.toString() val password = CharArray(binding.passwordText.length()); - binding.passwordText.text?.getChars(0, binding.passwordText.length(), password, 0); + (binding.passwordText.text as? android.text.GetChars)?.getChars(0, binding.passwordText.length(), password, 0); val actionResult = authClient.signUp( username = email, diff --git a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/PasswordResetNewPasswordFragment.kt b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/PasswordResetNewPasswordFragment.kt index 69a5f95700..a7c35dd198 100644 --- a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/PasswordResetNewPasswordFragment.kt +++ b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/PasswordResetNewPasswordFragment.kt @@ -75,7 +75,7 @@ class PasswordResetNewPasswordFragment : Fragment() { CoroutineScope(Dispatchers.Main).launch { try { val password = CharArray(binding.passwordText.length()); - binding.passwordText.text?.getChars(0, binding.passwordText.length(), password, 0); + (binding.passwordText.text as? android.text.GetChars)?.getChars(0, binding.passwordText.length(), password, 0); val actionResult = currentState.submitPassword(password) diff --git a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/SignUpPasswordFragment.kt b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/SignUpPasswordFragment.kt index 5c87a65f63..6f37785ad9 100644 --- a/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/SignUpPasswordFragment.kt +++ b/testapps/testapp/src/main/java/com/microsoft/identity/client/testapp/nativeauth/SignUpPasswordFragment.kt @@ -76,7 +76,7 @@ class SignUpPasswordFragment : Fragment() { CoroutineScope(Dispatchers.Main).launch { try { val password = CharArray(binding.passwordText.length()); - binding.passwordText.text?.getChars(0, binding.passwordText.length(), password, 0); + (binding.passwordText.text as? android.text.GetChars)?.getChars(0, binding.passwordText.length(), password, 0); val actionResult = currentState.submitPassword(password)