| import groovy.transform.Field |
| |
| pluginManagement { |
| repositories { |
| maven { |
| url = new File(buildscript.sourceFile.parent + "/../../prebuilts/androidx/external").getCanonicalFile() |
| } |
| if (System.getenv("ALLOW_PUBLIC_REPOS") != null || System.getProperty("ALLOW_PUBLIC_REPOS") != null) { |
| mavenCentral() |
| google() |
| maven { |
| url = "https://plugins.gradle.org/m2/" |
| } |
| } |
| } |
| } |
| |
| buildscript { |
| ext.supportRootFolder = buildscript.sourceFile.getParentFile() |
| apply(from: "buildSrc/repos.gradle") |
| repos.addMavenRepositories(repositories) |
| |
| dependencies { |
| classpath("com.gradle:gradle-enterprise-gradle-plugin:3.10.2") |
| classpath("com.gradle:common-custom-user-data-gradle-plugin:1.7.2") |
| classpath("androidx.build.gradle.gcpbuildcache:gcpbuildcache:1.0.0-alpha05") |
| } |
| } |
| |
| // Abort immediately if we're running in Studio, but not a managed instance of Studio. |
| if (startParameter.projectProperties.containsKey('android.injected.invoked.from.ide')) { |
| def expectedAgpVersion = System.getenv().get("EXPECTED_AGP_VERSION") |
| if (expectedAgpVersion == null) { |
| throw new Exception("Android Studio must be run from studiow or gradlew studio.") |
| } |
| } |
| |
| // Makes strong assumptions about the project structure. |
| def prebuiltsRoot = new File( |
| buildscript.sourceFile.parentFile.parentFile.parentFile, |
| "prebuilts" |
| ).absolutePath |
| def rootProjectRepositories |
| |
| apply from: "buildSrc/out.gradle" |
| def (outDir, buildSrcOut) = init.getOutDir() |
| |
| getGradle().beforeProject { |
| // Migrate to dependencyResolutionManagement.repositories when |
| // https://github.com/gradle/gradle/issues/17295 is fixed |
| if (it.path == ":") { |
| repos.addMavenRepositories(it.repositories) |
| rootProjectRepositories = it.repositories |
| |
| // Set buildSrcOut and outDir extras on root project |
| it.ext.buildSrcOut = buildSrcOut |
| it.ext.outDir = outDir |
| } else { |
| // Performance optimization because it is more efficient to reuse |
| // repositories from the root project than recreate identical ones |
| // on each project |
| it.repositories.addAll(rootProjectRepositories) |
| } |
| it.ext.prebuiltsRoot = prebuiltsRoot |
| // Expected out directory structure for :foo:bar is out/androidx/foo/bar |
| it.buildDir = new File(outDir, "androidx/${it.path.replace(":", "/")}/build") |
| } |
| |
| apply(plugin: "com.gradle.enterprise") |
| apply(plugin: "com.gradle.common-custom-user-data-gradle-plugin") |
| apply(plugin: "androidx.build.gradle.gcpbuildcache") |
| |
| gradleEnterprise { |
| server = "https://ge.androidx.dev" |
| |
| buildScan { |
| capture { |
| taskInputFiles = true |
| } |
| obfuscation { |
| hostname { host -> "unset" } |
| ipAddresses { addresses -> addresses.collect { address -> "0.0.0.0"} } |
| } |
| def buildNumber = System.getenv("BUILD_NUMBER") |
| if (buildNumber != null) { |
| value("BUILD_NUMBER", buildNumber) |
| link("ci.android.com build", "https://ci.android.com/builds/branches/aosp-androidx-main/grid?head=$buildNumber&tail=$buildNumber") |
| } |
| value("androidx.compose.multiplatformEnabled", isMultiplatformEnabled().toString()) |
| value("androidx.projects", getRequestedProjectSubsetName() ?: "Unset") |
| value("androidx.useMaxDepVersions", providers.gradleProperty("androidx.useMaxDepVersions").isPresent().toString()) |
| |
| publishAlways() |
| publishIfAuthenticated() |
| } |
| } |
| |
| rootProject.name = "androidx" |
| |
| dependencyResolutionManagement { |
| versionCatalogs { |
| libs { |
| def metalavaOverride = System.getenv("METALAVA_VERSION") |
| if (metalavaOverride != null) { |
| logger.warn("Using custom version ${metalavaOverride} of metalava due to METALAVA_VERSION being set.") |
| version('metalava', metalavaOverride) |
| } |
| def skikoOverride = System.getenv("SKIKO_VERSION") |
| if (skikoOverride != null) { |
| logger.warn("Using custom version ${skikoOverride} of SKIKO due to SKIKO_VERSION being set.") |
| version('skiko', skikoOverride) |
| } |
| String os = System.getProperty("os.name").toLowerCase(Locale.US) |
| String currentOsArtifact |
| if (os.contains("mac os x") || os.contains("darwin") || os.contains("osx")) { |
| def arch = System.getProperty("os.arch") |
| if (arch == "aarch64") { |
| currentOsArtifact = "skiko-awt-runtime-macos-arm64" |
| } else { |
| currentOsArtifact = "skiko-awt-runtime-macos-x64" |
| } |
| } else if (os.startsWith("win")) { |
| currentOsArtifact = "skiko-awt-runtime-windows-x64" |
| } else if (os.startsWith("linux") ) { |
| def arch = System.getProperty("os.arch") |
| if (arch == "aarch64") { |
| currentOsArtifact = "skiko-awt-runtime-linux-arm64" |
| } else { |
| currentOsArtifact = "skiko-awt-runtime-linux-x64" |
| } |
| } else { |
| throw GradleException("Unsupported operating system $os") |
| } |
| library("skikoCurrentOs", "org.jetbrains.skiko", currentOsArtifact).versionRef("skiko") |
| } |
| } |
| } |
| |
| boolean isMultiplatformEnabled() { |
| def mppParameter = properties.get("androidx.compose.multiplatformEnabled") |
| if (mppParameter == null) return false |
| return Boolean.parseBoolean(mppParameter) |
| } |
| |
| ///////////////////////////// |
| // |
| // Buildscript utils |
| // |
| ///////////////////////////// |
| |
| enum BuildType { |
| MAIN, |
| COMPOSE, |
| FLAN, |
| MEDIA, |
| WEAR, |
| GLANCE, |
| TOOLS, |
| KMP |
| } |
| |
| private String getRequestedProjectSubsetName() { |
| def prop = providers.gradleProperty("androidx.projects") |
| if (prop.isPresent()) { |
| return prop.get().toUpperCase() |
| } |
| |
| def envProp = providers.environmentVariable("ANDROIDX_PROJECTS") |
| if (envProp.isPresent()) { |
| return envProp.get().toUpperCase() |
| } |
| return null |
| } |
| |
| boolean isAllProjects() { |
| String projectSubsetName = getRequestedProjectSubsetName() |
| return requestedProjectSubsetName == null || requestedProjectSubsetName == "ALL" |
| } |
| |
| private Set<BuildType> createRequestedFilter() { |
| |