[go: nahoru, domu]

[GH] Use latest ndk for presubmit

Bug: 216535050
Test: CI

This is an imported pull request from https://github.com/androidx/androidx/pull/314.

Resolves #314
Github-Pr-Head-Sha: 819d0b781df1c6cd4af94ea82530171021b214e3
GitOrigin-RevId: 6bb7dc1a5902beb71ea2f72dda040710d822be1d
Change-Id: I51b7a9c33d8f0408f5c4cca6be55a5e05684747f
diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml
index 1b9652b..9879b21 100644
--- a/.github/workflows/presubmit.yml
+++ b/.github/workflows/presubmit.yml
@@ -62,6 +62,7 @@
         run: |
           set -x
           echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV
+          echo "ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV
 
       - name: "Checkout androidx repo"
         uses: actions/checkout@v2
@@ -170,6 +171,9 @@
         run: |
           set -x
           echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV
+          # use latest NDK because the default NDK on github is older.
+          # TODO b/216535050: Implement task to install the exact AndroidX ndk version.
+          echo "ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV
       # gradle action loads the dependencies cache only on the first run based on arguments.
       # to control it, we explicitly invoke it once which makes it load the dependencies cache with the parameters
       # we control
@@ -180,7 +184,7 @@
           JAVA_HOME: ${{ steps.setup-java.outputs.path }}
           JAVA_TOOLS_JAR: ${{ steps.setup-tools-jar.outputs.toolsJar }}
         with:
-          arguments: tasks -PandroidXUnusedParameter=${{ env.project-root }} # add project name to cache key
+          arguments: projects -PandroidXUnusedParameter=${{ env.project-root }} # add project name to cache key
           build-root-directory: ${{ env.project-root }}
           configuration-cache-enabled: false
           dependencies-cache-enabled: true
diff --git a/compose/ui/ui/build.gradle b/compose/ui/ui/build.gradle
index a18f016..1fddee8 100644
--- a/compose/ui/ui/build.gradle
+++ b/compose/ui/ui/build.gradle
@@ -106,7 +106,7 @@
     }
 }
 
-packageInspector(project, project(":compose:ui:ui-inspection"))
+packageInspector(project, ":compose:ui:ui-inspection")
 
 if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
     androidXComposeMultiplatform {
diff --git a/inspection/inspection-gradle-plugin/src/main/kotlin/androidx/inspection/gradle/InspectionPlugin.kt b/inspection/inspection-gradle-plugin/src/main/kotlin/androidx/inspection/gradle/InspectionPlugin.kt
index 83fe07c..1ad57b5 100644
--- a/inspection/inspection-gradle-plugin/src/main/kotlin/androidx/inspection/gradle/InspectionPlugin.kt
+++ b/inspection/inspection-gradle-plugin/src/main/kotlin/androidx/inspection/gradle/InspectionPlugin.kt
@@ -144,13 +144,21 @@
  * Use this function in [libraryProject] to include inspector that will be compiled into
  * inspector.jar and packaged in the library's aar.
  *
- * @param libraryProject project that is inspected and which aar will host inspector.jar . E.g
- * work-runtime
- * @param inspectorProject project of inspector, that will be compiled into inspector.jar. E.g
- * work-inspection
+ * @param libraryProject project that is inspected and which aar will host inspector.jar .
+ * E.g. work-runtime
+ * @param inspectorProjectPath project path of the inspector, that will be compiled into the
+ * inspector.jar. E.g. :work:work-inspection
  */
 @ExperimentalStdlibApi
-fun packageInspector(libraryProject: Project, inspectorProject: Project) {
+fun packageInspector(libraryProject: Project, inspectorProjectPath: String) {
+    val inspectorProject = libraryProject.rootProject.findProject(inspectorProjectPath)
+    if (inspectorProject == null) {
+        check(libraryProject.property("androidx.studio.type") == "playground") {
+            "Cannot find $inspectorProjectPath. This is optional only for playground builds."
+        }
+        // skip setting up inspector project
+        return
+    }
     val consumeInspector = libraryProject.createConsumeInspectionConfiguration()
 
     libraryProject.dependencies {
@@ -209,4 +217,4 @@
      * Name of built inspector artifact, if not provided it is equal to project's name.
      */
     var name: String? = null
-}
\ No newline at end of file
+}
diff --git a/playground-common/androidx-shared.properties b/playground-common/androidx-shared.properties
index cf0008f..415b6fb 100644
--- a/playground-common/androidx-shared.properties
+++ b/playground-common/androidx-shared.properties
@@ -41,4 +41,4 @@
 # org.gradle.vfs.watch=true
 org.gradle.unsafe.configuration-cache=true
 org.gradle.unsafe.configuration-cache-problems=warn
-org.gradle.unsafe.configuration-cache.max-problems=4000
\ No newline at end of file
+org.gradle.unsafe.configuration-cache.max-problems=4000
diff --git a/work/settings.gradle b/work/settings.gradle
index b8f2318..c0eac2e 100644
--- a/work/settings.gradle
+++ b/work/settings.gradle
@@ -27,12 +27,10 @@
 playground {
     setupPlayground("..")
     selectProjectsFromAndroidX({ name ->
+        if (name == ":work:work-inspection") return false
         if (name.startsWith(":work")) return true
         if (name.startsWith(":internal-testutils-runtime")) return true
         return false
     })
-
-    includeProject(":inspection:inspection", "inspection/inspection")
-    includeProject(":inspection:inspection-testing", "inspection/inspection-testing")
     includeProject(":inspection:inspection-gradle-plugin", "inspection/inspection-gradle-plugin")
 }
diff --git a/work/work-runtime/build.gradle b/work/work-runtime/build.gradle
index 6db8f53..5d63b10 100644
--- a/work/work-runtime/build.gradle
+++ b/work/work-runtime/build.gradle
@@ -79,7 +79,7 @@
     lintPublish(project(":work:work-runtime-lint"))
 }
 
-packageInspector(project, project(":work:work-inspection"))
+packageInspector(project, ":work:work-inspection")
 
 // KSP does not support argument per flavor so we set it to global instead.
 ksp {