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

Commit

Permalink
Move applicationVariant to upload task for lazy init.
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
x2on committed Dec 10, 2014
1 parent 51083a2 commit 60af274
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 1 addition & 15 deletions src/main/groovy/de/felixschulze/gradle/HockeyAppPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,7 @@ class HockeyAppPlugin implements Plugin<Project> {
HockeyAppUploadTask task = project.tasks.create("upload${variant.name.capitalize()}ToHockeyApp", HockeyAppUploadTask)
task.group = 'HockeyApp'
task.description = "Upload '${variant.name}' to HockeyApp"

// Get the first output apk file
variant.outputs.each {
if (FilenameUtils.isExtension(it.outputFile.getName(),"apk")) {
task.applicationFile = it.outputFile
return true
}
}

if (variant.getObfuscation()) {
task.mappingFile = variant.getMappingFile()
} else {
task.mightHaveMapping = false
}

task.applicationVariant = variant
task.variantName = variant.name
task.outputs.upToDateWhen { false }

Expand Down
18 changes: 18 additions & 0 deletions src/main/groovy/de/felixschulze/gradle/HockeyAppUploadTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@

package de.felixschulze.gradle

import com.android.build.gradle.api.ApplicationVariant
import de.felixschulze.gradle.util.ProgressHttpEntityWrapper
import de.felixschulze.teamcity.TeamCityProgressType
import de.felixschulze.teamcity.TeamCityStatusMessageHelper
import groovy.json.JsonSlurper
import org.apache.commons.io.FilenameUtils
import org.apache.http.HttpHost
import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
Expand All @@ -52,6 +54,7 @@ class HockeyAppUploadTask extends DefaultTask {
File symbolsDirectory
File mappingFile
String variantName
ApplicationVariant applicationVariant
boolean mightHaveMapping = true // Specify otherwise in Android config


Expand All @@ -64,6 +67,21 @@ class HockeyAppUploadTask extends DefaultTask {
@TaskAction
def upload() throws IOException {


// Get the first output apk file
applicationVariant.outputs.each {
if (FilenameUtils.isExtension(it.outputFile.getName(),"apk")) {
applicationFile = it.outputFile
return true
}
}

if (applicationVariant.getObfuscation()) {
mappingFile = applicationVariant.getMappingFile()
} else {
mightHaveMapping = false
}

if (!getApiToken()) {
throw new IllegalArgumentException("Cannot upload to HockeyApp because API Token is missing")
}
Expand Down

0 comments on commit 60af274

Please sign in to comment.