Skip to content

Commit

Permalink
Merge pull request #45 from DeployGate/retrieve-apk-location
Browse files Browse the repository at this point in the history
Retrieve APK file location from variant scope
  • Loading branch information
tnj authored Jun 20, 2017
2 parents b5326e8 + 7d66088 commit a10024a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dg deploy
1) Open your <code>build.gradle</code> on your project root and add a dependency.
```groovy
dependency {
classpath 'com.deploygate:gradle:1.1.2'
classpath 'com.deploygate:gradle:1.1.3'
}
```

Expand Down Expand Up @@ -140,6 +140,10 @@ Note that these values are used as default values so `build.gradle` may override

# Changes

## ver 1.1.3

* Restore auto configuring APK file path functionality (supports Android Gradle Plugin 3.0.0-alpha4)

## ver 1.1.2

* Fix failing first time upload with Free plans
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.jfrog.bintray'

group = 'com.deploygate'
archivesBaseName = 'gradle'
version = '1.1.2'
version = '1.1.3'

repositories {
mavenCentral()
Expand All @@ -13,6 +13,7 @@ repositories {
dependencies {
compile gradleApi()
compile localGroovy()

compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
compile 'org.apache.httpcomponents:httpmime:4.2.5'
runtime 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
Expand Down Expand Up @@ -51,7 +52,7 @@ bintray {
vcsUrl = 'https://github.com/DeployGate/gradle-deploygate-plugin.git'
githubRepo = 'DeployGate/gradle-deploygate-plugin'
version {
name = '1.1.2'
name = '1.1.3'
released = new Date()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.deploygate.gradle.plugins

class Config {
static final def VERSION = '1.0.4'
static final def VERSION = '1.1.3'
static final def USER_AGENT = "gradle-deploygate-plugin/${VERSION}"
static final def DEPLOYGATE_ROOT = 'https://deploygate.com'
}
20 changes: 15 additions & 5 deletions src/main/groovy/com/deploygate/gradle/plugins/DeployGate.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DeployGate implements Plugin<Project> {
project.android.applicationVariants.all { variant ->
// variant is for splits
variant.outputs.each { output ->
createTask(project, output, loginTask)
createTask(project, output, loginTask, variant)
tasksToCreate.remove output.name
}
}
Expand All @@ -53,7 +53,7 @@ class DeployGate implements Plugin<Project> {
}
}

private void createTask(project, output, loginTask) {
private void createTask(project, output, loginTask, variant = null) {
def name
def signingReady = true
def isUniversal = true
Expand All @@ -69,9 +69,7 @@ class DeployGate implements Plugin<Project> {

// TODO Workaround for 3.0.0 Preview, until the new API released
signingReady = output.hasProperty('variantOutputData') ? output.variantOutputData.variantData.signed : true
try {
outputFile = output.outputFile
} catch (Exception ignored) {}
outputFile = findOutputFile(output, variant)
}

def capitalized = name.capitalize()
Expand Down Expand Up @@ -108,6 +106,18 @@ class DeployGate implements Plugin<Project> {
}
}

def findOutputFile(output, variant) {
try {
// Android plugin < 3.0.0 way
return output.outputFile
} catch (Exception ignored) {}

if (variant) try {
// Android plugin 3.0.0-alpha way
return variant.variantData.scope.apkLocation
} catch (Exception ignored) {}
}

def createMultipleUploadTask(Project project, HashSet<String> dependsOn) {
if (dependsOn.empty) return
project.task 'uploadDeployGate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UploadTask extends DefaultTask {

DeployTarget target = findTarget()
if (!target.sourceFile?.exists())
throw new GradleException("APK file was not found. If you are using Android Build Tools >= 3.0.0, you need to set `sourceFile` in your build.gradle. See https://docs.deploygate.com/docs/gradle-plugin")
throw new GradleException("APK file ${target.sourceFile} was not found. If you are using Android Build Tools >= 3.0.0, you need to set `sourceFile` in your build.gradle. See https://docs.deploygate.com/docs/gradle-plugin")

onBeforeUpload(target)
def res = uploadProject(project, target)
Expand Down

0 comments on commit a10024a

Please sign in to comment.