-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,493 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../plugin/src/main/java/ru/kode/android/build/publish/plugin/extension/config/PlayConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ru.kode.android.build.publish.plugin.extension.config | ||
|
||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.provider.SetProperty | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFile | ||
|
||
interface PlayConfig { | ||
val name: String | ||
|
||
/** | ||
* The path to file with token for Google Play project | ||
*/ | ||
@get:InputFile | ||
val apiTokenFile: RegularFileProperty | ||
|
||
/** | ||
* appId in Google Play | ||
*/ | ||
@get:Input | ||
val appId: Property<String> | ||
|
||
/** | ||
* Track name of target app. Defaults to "internal" | ||
*/ | ||
@get:Input | ||
val trackId: Property<String> | ||
|
||
/** | ||
* Test groups for app distribution | ||
* | ||
* For example: [android-testers] | ||
*/ | ||
@get:Input | ||
val updatePriority: Property<Int> | ||
} |
96 changes: 96 additions & 0 deletions
96
...ugin/src/main/java/ru/kode/android/build/publish/plugin/task/play/PlayDistributionTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package ru.kode.android.build.publish.plugin.task.play | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.plugins.BasePlugin | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.provider.SetProperty | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFile | ||
import org.gradle.api.tasks.Optional | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.api.tasks.options.Option | ||
import org.gradle.workers.WorkQueue | ||
import org.gradle.workers.WorkerExecutor | ||
import ru.kode.android.build.publish.plugin.enity.mapper.fromJson | ||
import ru.kode.android.build.publish.plugin.extension.config.MAX_REQUEST_COUNT | ||
import ru.kode.android.build.publish.plugin.extension.config.MAX_REQUEST_DELAY_MS | ||
import ru.kode.android.build.publish.plugin.task.appcenter.work.AppCenterUploadWork | ||
import ru.kode.android.build.publish.plugin.task.play.work.PlayUploadWork | ||
import ru.kode.android.build.publish.plugin.util.capitalized | ||
import javax.inject.Inject | ||
|
||
abstract class PlayDistributionTask | ||
@Inject | ||
constructor( | ||
private val workerExecutor: WorkerExecutor, | ||
) : DefaultTask() { | ||
init { | ||
description = "Task to send apk to Google Play" | ||
group = BasePlugin.BUILD_GROUP | ||
} | ||
|
||
@get:InputFile | ||
@get:Option( | ||
option = "buildVariantOutputFile", | ||
description = "Artifact output file (absolute path is expected)", | ||
) | ||
abstract val buildVariantOutputFile: RegularFileProperty | ||
|
||
@get:InputFile | ||
@get:Option(option = "tagBuildFile", description = "Json contains info about tag build") | ||
abstract val tagBuildFile: RegularFileProperty | ||
|
||
@get:InputFile | ||
@get:Option( | ||
option = "apiTokenFile", | ||
description = "API token for google play console", | ||
) | ||
abstract val apiTokenFile: RegularFileProperty | ||
|
||
@get:Input | ||
@get:Option( | ||
option = "appId", | ||
description = "appId from Play Console", | ||
) | ||
abstract val appId: Property<String> | ||
|
||
|
||
@get:Input | ||
@get:Option( | ||
option = "trackId", | ||
description = "Track name of target app. Defaults to internal", | ||
) | ||
abstract val trackId: Property<String> | ||
|
||
@get:Input | ||
@get:Optional | ||
@get:Option( | ||
option = "updatePriority", | ||
description = "Update priority (0..5)", | ||
) | ||
abstract val updatePriority: Property<Int> | ||
|
||
@TaskAction | ||
fun upload() { | ||
val outputFile = buildVariantOutputFile.asFile.get() | ||
if (outputFile.extension != "aab") throw GradleException("file ${outputFile.path} is not bundle") | ||
val tag = fromJson(tagBuildFile.asFile.get()) | ||
val releaseName = "${tag.name}(${tag.buildVersion}.${tag.buildNumber})" | ||
val apiTokenFile = apiTokenFile.asFile.get() | ||
val workQueue: WorkQueue = workerExecutor.noIsolation() | ||
val trackId = trackId.orNull ?: "internal" | ||
val appId = appId.get() | ||
val updatePriority = updatePriority.orNull ?: 0 | ||
|
||
workQueue.submit(PlayUploadWork::class.java) { parameters -> | ||
parameters.appId.set(appId) | ||
parameters.apiToken.set(apiTokenFile) | ||
parameters.trackId.set(trackId) | ||
parameters.updatePriority.set(updatePriority) | ||
parameters.releaseName.set(releaseName) | ||
parameters.outputFile.set(outputFile) | ||
} | ||
} | ||
} |
Oops, something went wrong.