Run firebaseUploadReleaseProguardMapping from app / build.gradle

Is there a way to start the gradle task from the app / build.gradle file, so when I create the release of the APK, the firebaseUploadReleaseProguardMapping task will start automatically.

+5
source share
1 answer

You can use dependsOn for example (your app/build.gradle ):

 apply plugin: 'com.android.application' apply plugin: 'com.google.firebase.firebase-crash' android { } dependencies { } task release task archiveRelease(type: Copy) { from './build/outputs/apk', './build/outputs/' into "../releases/${rootProject.ext.configuration.version_code}" include('app-release.apk', 'mapping/release/mapping.txt') rename('app-release.apk', "${rootProject.ext.configuration.package}_${rootProject.ext.configuration.version_name}_${rootProject.ext.configuration.version_code}.apk") } project.afterEvaluate { dependencyUpdates.dependsOn clean assembleRelease.dependsOn clean def publishApkRelease = project.tasks.getByName("publishApkRelease") publishApkRelease.dependsOn assembleRelease release.dependsOn publishApkRelease, firebaseUploadReleaseProguardMapping, archiveRelease } 

I created a new task called release . It depends on publishApkRelease (comes from gradle-play-publisher ), firebaseUploadReleaseProguardMapping and archiveRelease . And publishApkRelease depends on assembleRelease .

In the first one, you simply call ./gradlew release and it will create your version of the release, upload the apk to the Google game, the mapping file in Firebase, and archive a copy of the apk and mapping file.

+1
source

Source: https://habr.com/ru/post/1261986/


All Articles