Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Commit

Permalink
Merge pull request #67 from jleidgens/master
Browse files Browse the repository at this point in the history
Creating a task that uploads all possible variants to HockeyApp
  • Loading branch information
x2on committed Sep 7, 2015
2 parents 73f38e8 + 9f92b20 commit 1152390
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/main/groovy/de/felixschulze/gradle/HockeyAppPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package de.felixschulze.gradle
import com.android.build.gradle.api.ApplicationVariant
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import com.android.build.gradle.AppExtension
import com.android.build.gradle.AppPlugin

Expand All @@ -50,16 +51,23 @@ class HockeyAppPlugin implements Plugin<Project> {

if (project.plugins.hasPlugin(AppPlugin)) {
AppExtension android = project.android
android.applicationVariants.all { ApplicationVariant variant ->
Task uploadAllTask = project.tasks.create("uploadToHockeyApp", Task);
uploadAllTask.group = GROUP_NAME
uploadAllTask.description = "Uploads all variants to HockeyApp"
uploadAllTask.outputs.upToDateWhen { false }
String uploadAllPath = uploadAllTask.getPath();

android.applicationVariants.all { ApplicationVariant variant ->
HockeyAppUploadTask task = project.tasks.create("upload${variant.name.capitalize()}ToHockeyApp", HockeyAppUploadTask)
task.group = GROUP_NAME
task.description = "Upload '${variant.name}' to HockeyApp"
task.applicationVariant = variant
task.variantName = variant.name
task.outputs.upToDateWhen { false }

task.dependsOn variant.assemble
task.uploadAllPath = uploadAllPath

uploadAllTask.dependsOn(task)
}
} else {
project.task('uploadToHockeyApp', type: HockeyAppUploadTask, group: GROUP_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class HockeyAppUploadTask extends DefaultTask {
ApplicationVariant applicationVariant
boolean mappingFileCouldBePresent = true
HockeyAppPluginExtension hockeyApp
String uploadAllPath


HockeyAppUploadTask() {
Expand Down Expand Up @@ -138,11 +139,16 @@ class HockeyAppUploadTask extends DefaultTask {
if (hockeyApp.variantToApplicationId) {
appId = hockeyApp.variantToApplicationId[variantName]
if (!appId) {
throw new IllegalArgumentException("Could not resolve app ID for variant: ${variantName} in the variantToApplicationId map.")
if(project.getGradle().getTaskGraph().hasTask(uploadAllPath)) {
logger.error("Could not resolve app ID for variant: ${variantName} in the variantToApplicationId map.")
} else {
throw new IllegalArgumentException("Could not resolve app ID for variant: ${variantName} in the variantToApplicationId map.")
}
}
}

uploadAppplicationFileToHockeyApp(applicationFile, mappingFile, appId)
if(appId) {
uploadAppplicationFileToHockeyApp(applicationFile, mappingFile, appId)
}
}

def void uploadAppplicationFileToHockeyApp(File appFile, @Nullable File mappingFile, String appId) {
Expand Down

0 comments on commit 1152390

Please sign in to comment.