-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to apply plugin to library module
- Loading branch information
1 parent
ae23924
commit 2647fdf
Showing
13 changed files
with
375 additions
and
15 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
easylauncher/src/main/kotlin/com/project/starter/easylauncher/plugin/AgpUtils.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,23 @@ | ||
package com.project.starter.easylauncher.plugin | ||
|
||
import com.android.build.gradle.AppExtension | ||
import com.android.build.gradle.LibraryExtension | ||
import com.android.build.gradle.api.BaseVariant | ||
import org.gradle.api.DomainObjectSet | ||
import org.gradle.api.Project | ||
|
||
private val supportedPlugins = listOf( | ||
"com.android.application", | ||
"com.android.library", | ||
) | ||
|
||
internal fun Project.configureSupportedPlugins(block: (DomainObjectSet<out BaseVariant>) -> Unit) { | ||
supportedPlugins.forEach { pluginId -> | ||
pluginManager.withPlugin(pluginId) { block(findVariants()) } | ||
} | ||
} | ||
|
||
internal fun Project.findVariants(): DomainObjectSet<out BaseVariant> = | ||
extensions.findByType(AppExtension::class.java)?.applicationVariants | ||
?: extensions.findByType(LibraryExtension::class.java)?.libraryVariants | ||
?: this.objects.domainObjectSet(BaseVariant::class.java) |
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
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,53 @@ | ||
apply plugin: 'com.starter.library.android' | ||
apply plugin: 'com.starter.easylauncher' | ||
apply plugin: 'com.facebook.testing.screenshot' | ||
|
||
android { | ||
defaultConfig { | ||
minSdkVersion(26) | ||
testInstrumentationRunner "com.starter.easylauncher.ScreenshotsRunner" | ||
} | ||
|
||
testOptions.unitTests.includeAndroidResources true | ||
|
||
packagingOptions { | ||
exclude 'META-INF/LICENSE*' | ||
} | ||
|
||
libraryVariants.configureEach { variant -> | ||
variant.mergedFlavor.applicationIdSuffix = variant.name | ||
if (variant.flavorName == "") { | ||
variant.mergedFlavor.manifestPlaceholders = [appName: "$project.name"] | ||
} else { | ||
variant.mergedFlavor.manifestPlaceholders = [appName: "$variant.flavorName"] | ||
} | ||
} | ||
} | ||
tasks.register("verifyAll") { | ||
android.libraryVariants.configureEach { variant -> | ||
dependsOn("verify${variant.flavorName.capitalize()}DebugAndroidTestScreenshotTest") | ||
} | ||
} | ||
tasks.register("recordAll") { | ||
android.libraryVariants.configureEach { variant -> | ||
dependsOn("record${variant.flavorName.capitalize()}DebugAndroidTestScreenshotTest") | ||
} | ||
} | ||
|
||
tasks.register("installAll") { | ||
android.libraryVariants.configureEach { variant -> | ||
dependsOn("install${variant.name.capitalize()}") | ||
} | ||
} | ||
|
||
tasks.withType(Test).configureEach { | ||
useJUnitPlatform() | ||
} | ||
screenshots { | ||
failureDir = "${buildDir}/failedScreenshots" | ||
} | ||
|
||
dependencies { | ||
implementation project(":adaptive-support") | ||
androidTestImplementation project(":screenshot-test-helpers") | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
...e/example-library/src/androidTest/kotlin/com/starter/easylauncher/screenshot/IconsTest.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,19 @@ | ||
package com.starter.easylauncher.screenshot | ||
|
||
import android.Manifest | ||
import androidx.test.rule.GrantPermissionRule | ||
import com.example.custom.adaptive.MainActivity | ||
import com.starter.easylauncher.recordScreenshot | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class IconsTest { | ||
|
||
@get:Rule | ||
val grantPermission = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE) | ||
|
||
@Test | ||
fun doScreenshot() { | ||
recordScreenshot<MainActivity>("library") | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.simple" | ||
> | ||
|
||
<application | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="${appName}" | ||
/> | ||
|
||
</manifest> |
Oops, something went wrong.