diff --git a/build-scripts/component-common.gradle b/build-scripts/component-common.gradle index d4d40326c6..5901331f74 100644 --- a/build-scripts/component-common.gradle +++ b/build-scripts/component-common.gradle @@ -12,15 +12,15 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - ndkVersion rootProject.ext.build.ndkVersion - compileSdkVersion rootProject.ext.build.compileSdkVersion - defaultConfig { - minSdkVersion rootProject.ext.build['minSdkVersion'] - targetSdkVersion rootProject.ext.build['targetSdkVersion'] + ndkVersion config.ndkVersion + compileSdkVersion config.compileSdkVersion + + minSdkVersion config.minSdkVersion + targetSdkVersion config.targetSdkVersion testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - buildConfigField("String", "LIBRARY_VERSION", "\"${rootProject.ext.library.version}\"") + buildConfigField("String", "LIBRARY_VERSION", "\"${config.componentsVersion}\"") } buildTypes { @@ -39,7 +39,7 @@ android { } kotlin { - jvmToolchain(rootProject.ext.build.jvmTargetCompatibility) + jvmToolchain(rootProject.config.jvmTargetCompatibility) } dependencies { diff --git a/build.gradle b/build.gradle index 38bc3501ed..a16784085c 100644 --- a/build.gradle +++ b/build.gradle @@ -2,8 +2,6 @@ buildscript { ext.build = [ - ndkVersion: "27.2.12479018", // Keep it in sync in TC Dockerfile. - // In general, we should aim to keep these in sync with AC compileSdkVersion: 35, targetSdkVersion: 35, diff --git a/megazords/full/android/build.gradle b/megazords/full/android/build.gradle index 2ab5fbe4b1..cf658eebd3 100644 --- a/megazords/full/android/build.gradle +++ b/megazords/full/android/build.gradle @@ -5,15 +5,14 @@ apply plugin: 'kotlin-android' android { namespace 'org.mozilla.appservices.full_megazord' - ndkVersion rootProject.ext.build.ndkVersion - compileSdkVersion rootProject.ext.build.compileSdkVersion - defaultConfig { - minSdkVersion rootProject.ext.build['minSdkVersion'] - targetSdkVersion rootProject.ext.build['targetSdkVersion'] + ndkVersion config.ndkVersion + compileSdkVersion config.compileSdkVersion + minSdkVersion config.minSdkVersion + targetSdkVersion config.targetSdkVersion testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - buildConfigField("String", "LIBRARY_VERSION", "\"${rootProject.ext.library.version}\"") + buildConfigField("String", "LIBRARY_VERSION", "\"${config.componentsVersion}\"") } buildTypes { @@ -29,7 +28,7 @@ android { } kotlin { - jvmToolchain(rootProject.ext.build.jvmTargetCompatibility) + jvmToolchain(rootProject.config.jvmTargetCompatibility) } // Configurations are a somewhat mysterious Gradle concept. For our purposes, we can treat them @@ -104,7 +103,7 @@ cargo { module = '..' // The Android NDK API level to target. - apiLevel = rootProject.ext.build['minSdkVersion'] + apiLevel = rootProject.config.minSdkVersion // Where Cargo writes its outputs. targetDirectory = '../../../target' @@ -122,7 +121,7 @@ cargo { exec = { spec, toolchain -> rootProject.ext.cargoExec(spec, toolchain) // Only used in the full megazord (that is, in this project) at build time. - spec.environment("MEGAZORD_VERSION", rootProject.ext.library.version) + spec.environment("MEGAZORD_VERSION", config.componentsVersion) } extraCargoBuildArguments = rootProject.ext.extraCargoBuildArguments @@ -159,11 +158,11 @@ afterEvaluate { extension "LICENSES.md" } pom { - groupId = rootProject.ext.library.groupId + groupId = rootProject.config.componentsGroupId artifactId = "${project.ext.artifactId}-libsForTests" description = project.ext.description // For mavenLocal publishing workflow, increment the version number every publish. - version = rootProject.ext.library.version + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') + version = rootProject.config.componentsVersion + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') packaging = "jar" licenses { diff --git a/publish.gradle b/publish.gradle index 20363545fe..5ccee73c32 100644 --- a/publish.gradle +++ b/publish.gradle @@ -10,7 +10,7 @@ def libUrl = properties.libUrl def libVcsUrl = properties.libVcsUrl ext.configurePublish = { - def theGroupId = rootProject.ext.library.groupId + def theGroupId = rootProject.config.componentsGroupId def theArtifactId = project.ext.artifactId def theDescription = project.ext.description @@ -42,7 +42,7 @@ ext.configurePublish = { // For mavenLocal publishing workflow, increment the version number every publish. // We only do this to the .pom file and not in $MEGAZORD_VERSION, because otherwise we // would need to rebuild the megazord .so on every publish, even if nothing else had changed. - version = rootProject.ext.library.version + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') + version = rootProject.config.componentsVersion + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') packaging = "aar" license { diff --git a/settings.gradle b/settings.gradle index b2dac69ecd..2d60c6e448 100644 --- a/settings.gradle +++ b/settings.gradle @@ -50,6 +50,10 @@ def setupProject(name, projectProps, appServicesRootDir) { // Expose the rest of the project properties, mostly for validation reasons. project.ext.configProps = projectProps project.ext.appServicesRootDir = appServicesRootDir + + if (gradle.hasProperty("mozconfig")) { + project.buildDir = "${gradle.mozconfig.topobjdir}/gradle/build/app-services/android/$name" + } } } } @@ -98,17 +102,56 @@ def calcGroupId(buildconfig) { } } +// This is a copy of the `Config` object used in moz-central (but with the addition of ndkVersion for UniFFI) +// This is only used when not in mozilla-central - on m-c the existing Config class is used. +// In the short term we should keep them in sync. +// Once in moz-central we should remove this. +class Config { + // This "componentsVersion" number is defined in "version.txt" and should follow + // semantic versioning (MAJOR.MINOR.PATCH). See https://semver.org/ + public final String componentsVersion + public final String componentsGroupId + public final Integer jvmTargetCompatibility + public final Integer compileSdkVersion + public final Integer minSdkVersion + public final Integer targetSdkVersion + public final String ndkVersion + + Config( + String componentsVersion, + String componentsGroupId, + Integer jvmTargetCompatibility, + Integer compileSdkVersion, + Integer minSdkVersion, + Integer targetSdkVersion, + String ndkVersion + ) { + this.componentsVersion = componentsVersion + this.componentsGroupId = componentsGroupId + this.jvmTargetCompatibility = jvmTargetCompatibility + this.compileSdkVersion = compileSdkVersion + this.minSdkVersion = minSdkVersion + this.targetSdkVersion = targetSdkVersion + this.ndkVersion = ndkVersion + } +} gradle.projectsLoaded { -> // Wait until root project is "loaded" before we set "config" // Note that since this is set on "rootProject.ext", it will be "in scope" during the evaluation of all projects' // gradle files. This means that they can just access "config.", and it'll function properly - gradle.rootProject.ext.library = [ + + gradle.rootProject.ext.config = new Config( // You can use -Plocal=true to help with mavenLocal publishing workflow. // It makes a fake version number that's smaller than any published version, // which can be depended on specifically by the ./build-scripts/substitute-local-appservices.gradle // but which is unlikely to be depended on by accident otherwise. - version: calcVersion(buildconfig), - groupId: calcGroupId(buildconfig), - ] + calcVersion(buildconfig), // version, + calcGroupId(buildconfig), // componentsGroupId + 17, // jvmTargetCompatibility, + 35, // compileSdkVersion, + 21, // minSdkVersion, + 35, // targetSdkVersion, + "27.2.12479018", // ndkVersion - Keep it in sync in TC Dockerfile. + ) } diff --git a/tools/nimbus-gradle-plugin/build.gradle b/tools/nimbus-gradle-plugin/build.gradle index 5cb910a787..1adda90454 100644 --- a/tools/nimbus-gradle-plugin/build.gradle +++ b/tools/nimbus-gradle-plugin/build.gradle @@ -34,7 +34,7 @@ repositories { // any tokens (values wrapped in `@`s) with the value for that key in the tokens object. processResources { filter ReplaceTokens, tokens: [ - 'project.version': rootProject.ext.library.version + 'project.version': rootProject.config.componentsVersion ] } @@ -91,10 +91,10 @@ publishing { from components.java pom { - groupId = rootProject.ext.library.groupId + groupId = rootProject.config.componentsGroupId artifactId = archivesBaseName description = project.ext.description - version = rootProject.ext.library.version + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') + version = rootProject.config.componentsVersion + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') licenses { license { diff --git a/tools/nimbus-gradle-plugin/settings.gradle b/tools/nimbus-gradle-plugin/settings.gradle index 509585c82a..269caf97e3 100644 --- a/tools/nimbus-gradle-plugin/settings.gradle +++ b/tools/nimbus-gradle-plugin/settings.gradle @@ -29,6 +29,7 @@ def calcVersion(buildconfig) { } gradle.projectsLoaded { -> + // XXX - the above probably needs to be upgraded to actually use "config"?? // Wait until root project is "loaded" before we set "config" // Note that since this is set on "rootProject.ext", it will be "in scope" during the evaluation of all projects' // gradle files. This means that they can just access "config.", and it'll function properly