-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[distribution] Add Gradle plugin for distribution
- Loading branch information
Showing
8 changed files
with
176 additions
and
14 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
72 changes: 72 additions & 0 deletions
72
...rc/main/kotlin/com/emergetools/android/gradle/tasks/distribution/DistributionPreflight.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,72 @@ | ||
package com.emergetools.android.gradle.tasks.distribution | ||
|
||
import com.emergetools.android.gradle.tasks.base.BasePreflightTask | ||
import com.emergetools.android.gradle.util.preflight.Preflight | ||
import com.emergetools.android.gradle.util.preflight.PreflightFailure | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Optional | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
abstract class DistributionPreflight : BasePreflightTask() { | ||
|
||
@get:Input | ||
@get:Optional | ||
abstract val hasEmergeApiToken: Property<Boolean> | ||
|
||
@get:Input | ||
@get:Optional | ||
abstract val distributionApiKey: Property<String> | ||
|
||
@get:Input | ||
@get:Optional | ||
abstract val distributionTag: Property<String> | ||
|
||
@get:Input | ||
@get:Optional | ||
abstract val distributionEnabled: Property<Boolean> | ||
|
||
@get:Input | ||
abstract val variantName: Property<String> | ||
|
||
@get:Input | ||
abstract val hasDistributionImplementationDependency: Property<Boolean> | ||
|
||
@TaskAction | ||
fun execute() { | ||
val preflight = Preflight("Reaper preflight check") | ||
|
||
val hasEmergeApiToken = hasEmergeApiToken.getOrElse(false) | ||
preflight.add("Emerge API token set") { | ||
if (!hasEmergeApiToken) { | ||
throw PreflightFailure("Emerge API token not set. See https://docs.emergetools.com/docs/uploading-basics#obtain-an-api-key") | ||
} | ||
} | ||
|
||
val variantName = variantName.get() | ||
preflight.add("enabled for variant: $variantName") { | ||
if (!distributionEnabled.getOrElse(false)) { | ||
throw PreflightFailure("Distribution not enabled for variant $variantName. Make sure \"${variantName}\" is included in `distribution.enabledVariants`") | ||
} | ||
} | ||
|
||
preflight.add("apiKey set") { | ||
val key = distributionApiKey.orNull | ||
if (key == null) { | ||
throw PreflightFailure("apiKey not set. See https://docs.emergetools.com/docs/distribution-setup-android#configure-the-sdk") | ||
} | ||
if (key == "") { | ||
throw PreflightFailure("apiKey must not be empty. See https://docs.emergetools.com/docs/distribution-setup-android#configure-the-sdk") | ||
} | ||
} | ||
|
||
preflight.add("Runtime SDK added") { | ||
if (!hasDistributionImplementationDependency.getOrElse(false)) { | ||
throw PreflightFailure("Distribution runtime SDK missing as an implementation dependency. See https://docs.emergetools.com/docs/distribution-setup-android#install-the-sdk") | ||
} | ||
} | ||
|
||
preflight.addSubPreflight(buildVcsPreflight()) | ||
preflight.logOutput(logger) | ||
} | ||
} |
Empty file.
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