Skip to content

Commit a10024a

Browse files
authored
Merge pull request #45 from DeployGate/retrieve-apk-location
Retrieve APK file location from variant scope
2 parents b5326e8 + 7d66088 commit a10024a

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dg deploy
2323
1) Open your <code>build.gradle</code> on your project root and add a dependency.
2424
```groovy
2525
dependency {
26-
classpath 'com.deploygate:gradle:1.1.2'
26+
classpath 'com.deploygate:gradle:1.1.3'
2727
}
2828
```
2929

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

141141
# Changes
142142

143+
## ver 1.1.3
144+
145+
* Restore auto configuring APK file path functionality (supports Android Gradle Plugin 3.0.0-alpha4)
146+
143147
## ver 1.1.2
144148

145149
* Fix failing first time upload with Free plans

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.jfrog.bintray'
44

55
group = 'com.deploygate'
66
archivesBaseName = 'gradle'
7-
version = '1.1.2'
7+
version = '1.1.3'
88

99
repositories {
1010
mavenCentral()
@@ -13,6 +13,7 @@ repositories {
1313
dependencies {
1414
compile gradleApi()
1515
compile localGroovy()
16+
1617
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
1718
compile 'org.apache.httpcomponents:httpmime:4.2.5'
1819
runtime 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
@@ -51,7 +52,7 @@ bintray {
5152
vcsUrl = 'https://github.com/DeployGate/gradle-deploygate-plugin.git'
5253
githubRepo = 'DeployGate/gradle-deploygate-plugin'
5354
version {
54-
name = '1.1.2'
55+
name = '1.1.3'
5556
released = new Date()
5657
}
5758
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.deploygate.gradle.plugins
22

33
class Config {
4-
static final def VERSION = '1.0.4'
4+
static final def VERSION = '1.1.3'
55
static final def USER_AGENT = "gradle-deploygate-plugin/${VERSION}"
66
static final def DEPLOYGATE_ROOT = 'https://deploygate.com'
77
}

src/main/groovy/com/deploygate/gradle/plugins/DeployGate.groovy

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class DeployGate implements Plugin<Project> {
4343
project.android.applicationVariants.all { variant ->
4444
// variant is for splits
4545
variant.outputs.each { output ->
46-
createTask(project, output, loginTask)
46+
createTask(project, output, loginTask, variant)
4747
tasksToCreate.remove output.name
4848
}
4949
}
@@ -53,7 +53,7 @@ class DeployGate implements Plugin<Project> {
5353
}
5454
}
5555

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

7070
// TODO Workaround for 3.0.0 Preview, until the new API released
7171
signingReady = output.hasProperty('variantOutputData') ? output.variantOutputData.variantData.signed : true
72-
try {
73-
outputFile = output.outputFile
74-
} catch (Exception ignored) {}
72+
outputFile = findOutputFile(output, variant)
7573
}
7674

7775
def capitalized = name.capitalize()
@@ -108,6 +106,18 @@ class DeployGate implements Plugin<Project> {
108106
}
109107
}
110108

109+
def findOutputFile(output, variant) {
110+
try {
111+
// Android plugin < 3.0.0 way
112+
return output.outputFile
113+
} catch (Exception ignored) {}
114+
115+
if (variant) try {
116+
// Android plugin 3.0.0-alpha way
117+
return variant.variantData.scope.apkLocation
118+
} catch (Exception ignored) {}
119+
}
120+
111121
def createMultipleUploadTask(Project project, HashSet<String> dependsOn) {
112122
if (dependsOn.empty) return
113123
project.task 'uploadDeployGate',

src/main/groovy/com/deploygate/gradle/plugins/tasks/UploadTask.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class UploadTask extends DefaultTask {
2929

3030
DeployTarget target = findTarget()
3131
if (!target.sourceFile?.exists())
32-
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")
32+
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")
3333

3434
onBeforeUpload(target)
3535
def res = uploadProject(project, target)

0 commit comments

Comments
 (0)