-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Getting a-s and m-c almost working with identical gradle files
- Loading branch information
Showing
4 changed files
with
118 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'org.mozilla.rust-android-gradle.rust-android' | ||
apply plugin: 'kotlin-android' | ||
|
||
if (!gradle.hasProperty("mozconfig")) { | ||
apply plugin: 'org.mozilla.rust-android-gradle.rust-android' | ||
} | ||
|
||
android { | ||
namespace 'org.mozilla.appservices.full_megazord' | ||
|
||
|
@@ -69,62 +72,63 @@ dependencies { | |
} | ||
} | ||
|
||
// Extract JNI dispatch libraries from the JAR into a directory, so that we can then package them | ||
// into our own megazord-desktopLibraries JAR. | ||
def extractLibJniDispatch = tasks.register("extractLibJniDispatch", Copy) { | ||
from zipTree(configurations.jna.singleFile).matching { | ||
include "**/libjnidispatch.*" | ||
if (!gradle.hasProperty("mozconfig")) { | ||
// Extract JNI dispatch libraries from the JAR into a directory, so that we can then package them | ||
// into our own megazord-desktopLibraries JAR. | ||
def extractLibJniDispatch = tasks.register("extractLibJniDispatch", Copy) { | ||
from zipTree(configurations.jna.singleFile).matching { | ||
include "**/libjnidispatch.*" | ||
} | ||
into layout.buildDirectory.dir("libjnidispatch").get() | ||
} | ||
into layout.buildDirectory.dir("libjnidispatch").get() | ||
} | ||
|
||
def packageLibsForTest = tasks.register("packageLibsForTest", Jar) { | ||
archiveBaseName = "full-megazord-libsForTests" | ||
def packageLibsForTest = tasks.register("packageLibsForTest", Jar) { | ||
archiveBaseName = "full-megazord-libsForTests" | ||
|
||
from extractLibJniDispatch | ||
from layout.buildDirectory.dir("rustJniLibs/desktop") | ||
dependsOn tasks["cargoBuild${rootProject.ext.nativeRustTarget.capitalize()}"] | ||
} | ||
from extractLibJniDispatch | ||
from layout.buildDirectory.dir("rustJniLibs/desktop") | ||
dependsOn tasks["cargoBuild${rootProject.ext.nativeRustTarget.capitalize()}"] | ||
} | ||
|
||
def copyMegazordNative = tasks.register("copyMegazordNative", Copy) { | ||
from layout.buildDirectory.dir("rustJniLibs/desktop") | ||
into layout.buildDirectory.dir("megazordNative") | ||
} | ||
def copyMegazordNative = tasks.register("copyMegazordNative", Copy) { | ||
from layout.buildDirectory.dir("rustJniLibs/desktop") | ||
into layout.buildDirectory.dir("megazordNative") | ||
} | ||
|
||
artifacts { | ||
// Connect task output to configurations | ||
libsForTests(packageLibsForTest) | ||
megazordNative(copyMegazordNative) | ||
} | ||
|
||
artifacts { | ||
// Connect task output to the configurations | ||
libsForTests(packageLibsForTest) | ||
megazordNative(copyMegazordNative) | ||
} | ||
cargo { | ||
// The directory of the Cargo.toml to build. | ||
module = '..' | ||
|
||
cargo { | ||
// The directory of the Cargo.toml to build. | ||
module = '..' | ||
// The Android NDK API level to target. | ||
apiLevel = rootProject.config.minSdkVersion | ||
|
||
// The Android NDK API level to target. | ||
apiLevel = rootProject.config.minSdkVersion | ||
// Where Cargo writes its outputs. | ||
targetDirectory = '../../../target' | ||
|
||
// Where Cargo writes its outputs. | ||
targetDirectory = '../../../target' | ||
libname = 'megazord' | ||
|
||
libname = 'megazord' | ||
// The Cargo targets to invoke. The mapping from short name to target | ||
// triple is defined by the `rust-android-gradle` plugin. | ||
targets = rootProject.ext.rustTargets | ||
|
||
// The Cargo targets to invoke. The mapping from short name to target | ||
// triple is defined by the `rust-android-gradle` plugin. | ||
targets = rootProject.ext.rustTargets | ||
// Perform release builds (which should have debug info, due to | ||
// `debug = true` in Cargo.toml). | ||
profile = "release" | ||
|
||
// Perform release builds (which should have debug info, due to | ||
// `debug = true` in Cargo.toml). | ||
profile = "release" | ||
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", config.componentsVersion) | ||
} | ||
|
||
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", config.componentsVersion) | ||
extraCargoBuildArguments = rootProject.ext.extraCargoBuildArguments | ||
} | ||
|
||
extraCargoBuildArguments = rootProject.ext.extraCargoBuildArguments | ||
} | ||
|
||
afterEvaluate { | ||
|
@@ -134,57 +138,61 @@ afterEvaluate { | |
variant.productFlavors.each { | ||
productFlavor += "${it.name.capitalize()}" | ||
} | ||
def buildType = "${variant.buildType.name.capitalize()}" | ||
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(tasks["cargoBuild"]) | ||
if (!gradle.hasProperty("mozconfig")) { | ||
def buildType = "${variant.buildType.name.capitalize()}" | ||
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(tasks["cargoBuild"]) | ||
} | ||
} | ||
} | ||
|
||
apply from: "$appServicesRootDir/publish.gradle" | ||
ext.configurePublish() | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
// Publish a second package named `full-megazord-libsForTests` to Maven with the | ||
// `libsForTests` output. This contains the same content as our `libsForTests` | ||
// configuration. Publishing it allows the android-components code to depend on it. | ||
libsForTests(MavenPublication) { | ||
artifact tasks['packageLibsForTest'] | ||
artifact file("${projectDir}/../DEPENDENCIES.md"), { | ||
extension "LICENSES.md" | ||
} | ||
pom { | ||
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.config.componentsVersion + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') | ||
packaging = "jar" | ||
|
||
licenses { | ||
license { | ||
name = libLicense | ||
url = libLicenseUrl | ||
} | ||
if (!gradle.hasProperty("mozconfig")) { | ||
afterEvaluate { | ||
publishing { | ||
publications { | ||
// Publish a second package named `full-megazord-libsForTests` to Maven with the | ||
// `libsForTests` output. This contains the same content as our `libsForTests` | ||
// configuration. Publishing it allows the android-components code to depend on it. | ||
libsForTests(MavenPublication) { | ||
artifact tasks['packageLibsForTest'] | ||
artifact file("${projectDir}/../DEPENDENCIES.md"), { | ||
extension "LICENSES.md" | ||
} | ||
pom { | ||
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.config.componentsVersion + (rootProject.hasProperty('local') ? '-' + rootProject.property('local') : '') | ||
packaging = "jar" | ||
|
||
licenses { | ||
license { | ||
name = libLicense | ||
url = libLicenseUrl | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
name = 'Sync Team' | ||
email = '[email protected]' | ||
developers { | ||
developer { | ||
name = 'Sync Team' | ||
email = '[email protected]' | ||
} | ||
} | ||
} | ||
|
||
scm { | ||
connection = libVcsUrl | ||
developerConnection = libVcsUrl | ||
url = libUrl | ||
scm { | ||
connection = libVcsUrl | ||
developerConnection = libVcsUrl | ||
url = libUrl | ||
} | ||
} | ||
} | ||
|
||
// This is never the publication we want to use when publishing a | ||
// parent project with us as a child `project()` dependency. | ||
alias = true | ||
// This is never the publication we want to use when publishing a | ||
// parent project with us as a child `project()` dependency. | ||
alias = true | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters