2018-08-03 21:12:41 +03:00
|
|
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
ext.kotlin_version = '1.2.50'
|
2018-08-20 20:41:04 +03:00
|
|
|
|
|
|
|
ext.library = [
|
2018-11-27 00:23:53 +03:00
|
|
|
version: '0.11.0'
|
2018-08-20 20:41:04 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
ext.build = [
|
|
|
|
compileSdkVersion: 27,
|
|
|
|
targetSdkVersion: 27,
|
|
|
|
minSdkVersion: 21, // So that we can publish for aarch64.
|
|
|
|
]
|
|
|
|
|
2018-08-03 21:12:41 +03:00
|
|
|
repositories {
|
|
|
|
google()
|
|
|
|
jcenter()
|
2018-08-20 20:41:04 +03:00
|
|
|
maven {
|
|
|
|
url "https://plugins.gradle.org/m2/"
|
|
|
|
}
|
2018-08-03 21:12:41 +03:00
|
|
|
}
|
|
|
|
dependencies {
|
2018-11-20 03:38:04 +03:00
|
|
|
classpath 'com.android.tools.build:gradle:3.1.4'
|
2018-08-03 21:12:41 +03:00
|
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
|
|
|
2018-08-20 20:41:04 +03:00
|
|
|
// Publish.
|
2018-11-15 08:13:33 +03:00
|
|
|
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
|
|
|
|
classpath 'digital.wup:android-maven-publish:3.6.2'
|
2018-08-20 20:41:04 +03:00
|
|
|
|
2018-11-15 03:57:36 +03:00
|
|
|
classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.6.0'
|
2018-08-20 20:41:04 +03:00
|
|
|
|
2018-09-19 02:49:44 +03:00
|
|
|
// Yes, this is unusual. We want to access some host-specific
|
|
|
|
// computation at build time.
|
|
|
|
classpath 'net.java.dev.jna:jna:4.5.2'
|
|
|
|
|
2018-11-06 02:03:20 +03:00
|
|
|
// Downloading libs/ archives from Taskcluster.
|
|
|
|
classpath 'de.undercouch:gradle-download-task:3.4.3'
|
|
|
|
|
2018-08-03 21:12:41 +03:00
|
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
|
|
// in the individual module build.gradle files
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-06 02:03:20 +03:00
|
|
|
apply plugin: 'de.undercouch.download'
|
|
|
|
|
2018-08-03 21:12:41 +03:00
|
|
|
allprojects {
|
|
|
|
repositories {
|
|
|
|
google()
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-15 08:13:33 +03:00
|
|
|
subprojects {
|
|
|
|
apply plugin: 'digital.wup.android-maven-publish'
|
|
|
|
|
|
|
|
// This allows to invoke Gradle like `./gradlew publishToRootProjectBuildDir` (equivalent to
|
|
|
|
// `./gradlew publish`) and also `./gradlew publishToProjectBuildDir`.
|
|
|
|
publishing {
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = "rootProjectBuildDir"
|
|
|
|
url "file://${project.rootProject.buildDir}/maven"
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = "projectBuildDir"
|
|
|
|
url "file://${project.buildDir}/maven"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 21:12:41 +03:00
|
|
|
task clean(type: Delete) {
|
|
|
|
delete rootProject.buildDir
|
|
|
|
}
|
2018-11-06 01:16:40 +03:00
|
|
|
|
|
|
|
// Avoid Gradle namespace collision. This is here, rather than in `buildscript
|
|
|
|
// { ... }`, to avoid issues with importing.
|
|
|
|
import com.sun.jna.Platform as DefaultPlatform
|
|
|
|
|
2018-11-06 02:03:20 +03:00
|
|
|
// This is the output `git rev-parse HEAD:libs`. We could discover this automatically, but
|
|
|
|
// let's keep things simple and bump this manually for a while. If and when we grow SNAPSHOT
|
|
|
|
// support on maven.mozilla.org, we can invest in a better approach for versioning these
|
|
|
|
// prerequisite libraries.
|
|
|
|
//
|
|
|
|
// Set this to `= null` in order to use libs from the source directory.
|
2018-11-27 21:26:18 +03:00
|
|
|
ext.libsGitSha = 'ebc93cc7f561c908279f1850eacee34ab3739af3'
|
2018-11-06 02:03:20 +03:00
|
|
|
|
|
|
|
if (rootProject.ext.libsGitSha != null) {
|
|
|
|
task downloadAndroidLibs(type: Download) {
|
|
|
|
src "https://index.taskcluster.net/v1/task/project.application-services.application-services.build.libs.android.${rootProject.ext.libsGitSha}/artifacts/public/target.tar.gz"
|
|
|
|
dest new File(buildDir, "libs.android.${rootProject.ext.libsGitSha}.tar.gz")
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
if (it.dest.exists()) {
|
|
|
|
throw new StopExecutionException("File to download already exists: ${it.dest.path}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
overwrite true
|
|
|
|
}
|
|
|
|
|
|
|
|
task untarAndroidLibs(dependsOn: downloadAndroidLibs, type: Copy) {
|
|
|
|
from tarTree(downloadAndroidLibs.dest)
|
|
|
|
into rootProject.buildDir
|
|
|
|
}
|
|
|
|
|
|
|
|
task downloadDesktopLibs(type: Download) {
|
|
|
|
src {
|
|
|
|
switch (DefaultPlatform.RESOURCE_PREFIX) {
|
|
|
|
case 'darwin':
|
|
|
|
return "https://index.taskcluster.net/v1/task/project.application-services.application-services.build.libs.desktop.macos.${rootProject.ext.libsGitSha}/artifacts/public/target.tar.gz"
|
|
|
|
case 'linux-x86-64':
|
|
|
|
return "https://index.taskcluster.net/v1/task/project.application-services.application-services.build.libs.desktop.linux.${rootProject.ext.libsGitSha}/artifacts/public/target.tar.gz"
|
|
|
|
default:
|
|
|
|
throw new GradleException("Unknown host platform '${DefaultPlatform.RESOURCE_PREFIX}'. " +
|
|
|
|
"Set `ext.libsGitSha = null` in ${rootProject.rootDir}/build.gradle and build your own libs. " +
|
|
|
|
"If you don't want to build your own libs for Android, you can untar\n\n${downloadAndroidLibs.src}\n\nat top-level to populate `libs/android/`. " +
|
|
|
|
"You'll need build your own libs for your host platform in order to be able to build and run unit tests.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dest {
|
|
|
|
switch (DefaultPlatform.RESOURCE_PREFIX) {
|
|
|
|
case 'darwin':
|
|
|
|
return new File(buildDir, "libs.desktop.macos.${rootProject.ext.libsGitSha}.tar.gz")
|
|
|
|
case 'linux-x86-64':
|
|
|
|
return new File(buildDir, "libs.desktop.linux.${rootProject.ext.libsGitSha}.tar.gz")
|
|
|
|
default:
|
|
|
|
throw new GradleException("Unknown host platform '${DefaultPlatform.RESOURCE_PREFIX}'. " +
|
|
|
|
"Set `ext.libsGitSha = null` in ${rootProject.rootDir}/build.gradle and build your own libs.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
if (it.dest.exists()) {
|
|
|
|
throw new StopExecutionException("File to download already exists: ${it.dest.path}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
overwrite true
|
|
|
|
}
|
|
|
|
|
|
|
|
task untarDesktopLibs(dependsOn: downloadDesktopLibs, type: Copy) {
|
|
|
|
from tarTree(downloadDesktopLibs.dest)
|
|
|
|
into rootProject.buildDir
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects { project ->
|
|
|
|
afterEvaluate {
|
|
|
|
android.libraryVariants.all { v ->
|
|
|
|
def task = v.preBuild
|
|
|
|
task.dependsOn(rootProject.untarAndroidLibs)
|
|
|
|
task.dependsOn(rootProject.untarDesktopLibs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-06 01:16:40 +03:00
|
|
|
// Configure some environment variables, per toolchain, that will apply during
|
|
|
|
// the Cargo build. We assume that the `libs/` directory has been populated
|
|
|
|
// before invoking Gradle (or Cargo).
|
|
|
|
ext.cargoExec = { spec, toolchain ->
|
|
|
|
spec.environment("OPENSSL_STATIC", "1")
|
|
|
|
|
2018-11-06 02:03:20 +03:00
|
|
|
// Use in-tree libs from the source directory in CI or if the git SHA is unset; otherwise use
|
|
|
|
// downloaded libs.
|
|
|
|
def libsRootDir = (System.getenv('CI') || ext.libsGitSha == null) ? rootProject.rootDir : rootProject.buildDir
|
|
|
|
|
2018-11-06 01:16:40 +03:00
|
|
|
switch (toolchain.platform) {
|
|
|
|
case 'default':
|
2018-11-06 02:03:20 +03:00
|
|
|
spec.environment("OPENSSL_DIR", new File(libsRootDir, "libs/desktop/${DefaultPlatform.RESOURCE_PREFIX}/openssl").absolutePath)
|
|
|
|
spec.environment("SQLCIPHER_LIB_DIR", new File(libsRootDir, "libs/desktop/${DefaultPlatform.RESOURCE_PREFIX}/sqlcipher/lib").absolutePath)
|
|
|
|
spec.environment("SQLCIPHER_INCLUDE_DIR", new File(libsRootDir, "libs/desktop/${DefaultPlatform.RESOURCE_PREFIX}/sqlcipher/include").absolutePath)
|
2018-11-06 01:16:40 +03:00
|
|
|
break;
|
|
|
|
case 'arm':
|
|
|
|
case 'arm64':
|
|
|
|
case 'x86':
|
|
|
|
case 'x86_64':
|
2018-11-06 02:03:20 +03:00
|
|
|
spec.environment("OPENSSL_DIR", new File(libsRootDir, "libs/android/${toolchain.platform}/openssl").absolutePath)
|
|
|
|
spec.environment("SQLCIPHER_LIB_DIR", new File(libsRootDir, "libs/android/${toolchain.platform}/sqlcipher/lib").absolutePath)
|
|
|
|
spec.environment("SQLCIPHER_INCLUDE_DIR", new File(libsRootDir, "libs/android/${toolchain.platform}/sqlcipher/include").absolutePath)
|
2018-11-06 01:16:40 +03:00
|
|
|
break;
|
|
|
|
default:
|
2018-11-06 02:03:20 +03:00
|
|
|
throw new GradleException("Unknown toolchain platform ${toolchain.platform}")
|
2018-11-06 01:16:40 +03:00
|
|
|
}
|
|
|
|
}
|