A set of re-usable Gradle scripts for Android apps and libraries.
Update your root build.gradle as per below.
- Add sdk releases as a buildscript repository
maven {
name = "github-aevi-appflow"
url = uri("https://maven.pkg.github.com/AEVI-AppFlow/gradle-scripts")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: gh_username
password = System.getenv("GITHUB_TOKEN") ?: gh_token
}
}- Add gradle-scripts as a buildscript dependency
classpath 'com.aevi.sdk.build:gradle-scripts:<version>'- Add a lambda at root of file
ext.gradleScript = { path ->
return rootProject.buildscript.classLoader.getResource(path).toURI()
}If you are using kts then you will need to add gradleScriptLoader at top of build.gradle.kts file
(don't forget to import import java.net.URI otherwise you will get error)
val gradleScriptLoader by extra(
fun(string: String): URI? {
var data: URI? = null
project.buildscript {
data = classLoader.getResource(string).toURI()
}
return data
}
)and then you can call
apply(from = gradleScriptLoader("root/common-tasks.gradle"))- Apply root scripts
apply from: gradleScript('root/common-tasks.gradle')- In your app/lib modules build.gradle Define required variables
ext.applicationId = "com.aevi.XXX"
ext.applicationName = "YourAppName"
ext.applicationTargetSdkVersion = <target>
ext.applicationMinSdkVersion = <min>- Apply relevant scripts
apply from: gradleScript('android/artifacts.gradle')
apply from: gradleScript('android/versioning.gradle')
apply from: gradleScript('android/basic-android.gradle')- Define/override Android settings as required
- Build types
- Flavors
- Etc
apply from: gradleScript('android/versioning.gradle')apply from: gradleScript('lib/versioning.gradle')This script will automatically generate gradle tasks for the publication of the libraries and APKs of your project
apply from: gradleScript('publish/publishing-utils.gradle')
publishingUtils?.publication {
groupId '...'
artifactId project.name
version libraryVersion
}It also has Github package publishing built-in support, assuming the build is being run from Github actions:
./gradlew app:assembleRelease
./gradlew app:publishReleasePublicationToGithubIn order to get automatic signing with the default SDK key, add the below to the relevant module gradle file
apply from: gradleScript('android/sdk-dev-signing-config.gradle')
apply from: gradleScript('android/common-build-types-v2.gradle')
The Github Actions workflow env block must have:
SDK_DEV_KEYSTORE: ${{ secrets.SDK_DEV_KEYSTORE }}
SDK_DEV_KEYSTORE_PASSWORD: ${{ secrets.SDK_DEV_KEYSTORE_PASSWORD }}
Copyright (c) 2021 AEVI International GmbH. All rights reserved Unauthorized copying or distribution of this project, via any medium is strictly prohibited Proprietary and confidential