Skip to content

Commit

Permalink
feat: Extract Android library
Browse files Browse the repository at this point in the history
  • Loading branch information
technoir42 committed Jul 8, 2024
1 parent 1aeb5e8 commit 040ba39
Show file tree
Hide file tree
Showing 276 changed files with 107 additions and 79 deletions.
75 changes: 4 additions & 71 deletions espresso-server/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ val appiumTargetPackage: String by project
val appiumSourceCompatibility: String by project
val appiumTargetCompatibility: String by project
val appiumJvmTarget: String by project
val appiumAndroidGradlePlugin: String by project
val appiumKotlin: String by project
val appiumAndroidxTestVersion: String by project
val appiumAnnotationVersion: String by project
Expand All @@ -27,6 +26,8 @@ val appiumUiAutomatorVersion: String by project
android {
compileSdk = appiumCompileSdk.toInt()
buildToolsVersion = appiumBuildTools
namespace = "io.appium.espressoserver"

defaultConfig {
// <instrumentation android:targetPackage=""/>
applicationId = appiumTargetPackage
Expand All @@ -48,16 +49,6 @@ android {
}
}

sourceSets {
getByName("test") {
java.srcDirs("src/androidTest/java")
}
}

testOptions {
unitTests.isReturnDefaultValues = true
}

signingConfigs {
getByName("debug") {
findProperty("appiumKeystoreFile")?.also {
Expand Down Expand Up @@ -90,71 +81,13 @@ android {
packaging {
resources.excludes.add("META-INF/**")
}

namespace = "io.appium.espressoserver"
}

dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
// additionalAppDependencies placeholder (don't change or delete this line)

testImplementation("androidx.annotation:annotation:$appiumAnnotationVersion")
testImplementation("androidx.test.espresso:espresso-contrib:$appiumEspressoVersion")
testImplementation("androidx.test.espresso:espresso-core:$appiumEspressoVersion")
testImplementation("androidx.test.espresso:espresso-web:$appiumEspressoVersion")
testImplementation("androidx.test.uiautomator:uiautomator:$appiumUiAutomatorVersion")
testImplementation("androidx.test:core:$appiumAndroidxTestVersion")
testImplementation("androidx.test:runner:$appiumAndroidxTestVersion")
testImplementation("androidx.test:rules:$appiumAndroidxTestVersion")
testImplementation("com.google.code.gson:gson:$appiumGsonVersion")
testImplementation("junit:junit:$appiumJUnitVersion")
testImplementation("org.mockito:mockito-core:$appiumMockitoVersion")
testImplementation("org.nanohttpd:nanohttpd-webserver:$appiumNanohttpdVersion")
testImplementation("org.robolectric:robolectric:$appiumRobolectricVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test:$appiumKotlin")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$appiumKotlin")
testImplementation("org.jetbrains.kotlin:kotlin-reflect:$appiumKotlin")
testImplementation("androidx.compose.ui:ui-test:$appiumComposeVersion")
testImplementation("androidx.compose.ui:ui-test-junit4:$appiumComposeVersion")

androidTestImplementation("androidx.annotation:annotation:$appiumAnnotationVersion")
androidTestImplementation("androidx.test.espresso:espresso-contrib:$appiumEspressoVersion") {
// Exclude transitive dependencies to limit conflicts with AndroidX libraries from AUT.
// Link to PR with fix and discussion https://github.com/appium/appium-espresso-driver/pull/596
isTransitive = false
}
androidTestImplementation("androidx.test.espresso:espresso-web:$appiumEspressoVersion") {
because("Espresso Web Atoms support (mobile: webAtoms)")
}
androidTestImplementation("androidx.test.uiautomator:uiautomator:$appiumUiAutomatorVersion") {
because("UiAutomator support (mobile: uiautomator)")
}
androidTestImplementation(project(":library"))
androidTestImplementation("junit:junit:$appiumJUnitVersion")
androidTestImplementation("androidx.test:core:$appiumAndroidxTestVersion")
androidTestImplementation("androidx.test:runner:$appiumAndroidxTestVersion")
androidTestImplementation("androidx.test:rules:$appiumAndroidxTestVersion")
androidTestImplementation("com.google.code.gson:gson:$appiumGsonVersion")
androidTestImplementation("org.nanohttpd:nanohttpd-webserver:$appiumNanohttpdVersion")
androidTestImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$appiumKotlin")
androidTestImplementation("org.jetbrains.kotlin:kotlin-reflect:$appiumKotlin")
androidTestImplementation("androidx.compose.ui:ui-test:$appiumComposeVersion") {
because("Android Compose support")
}
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$appiumComposeVersion") {
because("Android Compose support")
}

// additionalAndroidTestDependencies placeholder (don't change or delete this line)
}

configurations.all {
resolutionStrategy.eachDependency {
// To avoid "androidx.annotation:annotation" version conflict.
if (requested.group == "androidx.annotation" && !requested.name.contains("annotation")) {
useVersion(appiumAnnotationVersion)
}
}
}

tasks.withType<Test> {
systemProperty("skipespressoserver", "true")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package io.appium.espressoserver
import androidx.test.filters.LargeTest
import io.appium.espressoserver.lib.http.Server
import org.junit.Assert.assertEquals
import org.junit.Assume
import org.junit.Rule
import org.junit.Test

Expand All @@ -36,10 +35,6 @@ class EspressoServerRunnerTest {

@Test
fun startEspressoServer() {
if (System.getProperty("skipespressoserver") != null) {
Assume.assumeTrue(true)
return
}
server.run()

assertEquals(true, true) // Keep Codacy happy
Expand Down
2 changes: 2 additions & 0 deletions espresso-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ allprojects {
google()
mavenCentral()
}

group = "io.appium.espressoserver"
}

tasks.register("clean", Delete::class) {
Expand Down
90 changes: 90 additions & 0 deletions espresso-server/library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
plugins {
id("com.android.library")
kotlin("android")
}

val appiumCompileSdk: String by project
val appiumMinSdk: String by project
val appiumTargetSdk: String by project
val appiumBuildTools: String by project
val appiumSourceCompatibility: String by project
val appiumTargetCompatibility: String by project
val appiumJvmTarget: String by project
val appiumKotlin: String by project
val appiumAndroidxTestVersion: String by project
val appiumAnnotationVersion: String by project
val appiumComposeVersion: String by project
val appiumGsonVersion: String by project
val appiumEspressoVersion: String by project
val appiumNanohttpdVersion: String by project
val appiumRobolectricVersion: String by project
val appiumJUnitVersion: String by project
val appiumUiAutomatorVersion: String by project

android {
compileSdk = appiumCompileSdk.toInt()
buildToolsVersion = appiumBuildTools
namespace = "io.appium.espressoserver.lib"

defaultConfig {
minSdk = appiumMinSdk.toInt()
}

compileOptions {
sourceCompatibility = JavaVersion.valueOf(appiumSourceCompatibility.uppercase())
targetCompatibility = JavaVersion.valueOf(appiumTargetCompatibility.uppercase())
}

packaging {
resources.excludes.add("META-INF/**")
}

kotlinOptions {
jvmTarget = appiumJvmTarget
}

lint {
targetSdk = appiumTargetSdk.toInt()
}

testOptions {
targetSdk = appiumTargetSdk.toInt()
unitTests.isReturnDefaultValues = true
}
}

dependencies {
// additionalAppDependencies placeholder (don't change or delete this line)

api("androidx.annotation:annotation:$appiumAnnotationVersion")
api("androidx.test.espresso:espresso-contrib:$appiumEspressoVersion") {
// Exclude transitive dependencies to limit conflicts with AndroidX libraries from AUT.
// Link to PR with fix and discussion https://github.com/appium/appium-espresso-driver/pull/596
isTransitive = false
}
api("androidx.test.espresso:espresso-web:$appiumEspressoVersion") {
because("Espresso Web Atoms support (mobile: webAtoms)")
}
api("androidx.test.uiautomator:uiautomator:$appiumUiAutomatorVersion") {
because("UiAutomator support (mobile: uiautomator)")
}
api("androidx.test:core:$appiumAndroidxTestVersion")
api("androidx.test:runner:$appiumAndroidxTestVersion")
api("androidx.test:rules:$appiumAndroidxTestVersion")
api("com.google.code.gson:gson:$appiumGsonVersion")
api("org.nanohttpd:nanohttpd-webserver:$appiumNanohttpdVersion")
api("org.jetbrains.kotlin:kotlin-stdlib:$appiumKotlin")
api("org.jetbrains.kotlin:kotlin-reflect:$appiumKotlin")
api("androidx.compose.ui:ui-test:$appiumComposeVersion") {
because("Android Compose support")
}
api("androidx.compose.ui:ui-test-junit4:$appiumComposeVersion") {
because("Android Compose support")
}

testImplementation("androidx.test.espresso:espresso-contrib:$appiumEspressoVersion")
testImplementation("junit:junit:$appiumJUnitVersion")
testImplementation("org.robolectric:robolectric:$appiumRobolectricVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test:$appiumKotlin")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$appiumKotlin")
}
6 changes: 6 additions & 0 deletions espresso-server/library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package io.appium.espressoserver.lib.helpers

import androidx.compose.ui.semantics.SemanticsNode
import androidx.compose.ui.test.*
import io.appium.espressoserver.EspressoServerRunnerTest
import io.appium.espressoserver.lib.drivers.DriverContext
import io.appium.espressoserver.lib.handlers.exceptions.InvalidSelectorException
import io.appium.espressoserver.lib.model.Strategy
Expand Down
1 change: 1 addition & 0 deletions espresso-server/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include(":app")
include(":library")
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"espresso-server/app/build/outputs/apk",
"espresso-server/app/build.gradle.kts",
"espresso-server/app/proguard-rules.pro",
"espresso-server/library/src",
"espresso-server/library/build.gradle.kts",
"espresso-server/gradle",
"espresso-server/gradlew",
"espresso-server/gradlew.bat",
Expand Down Expand Up @@ -86,9 +88,9 @@
"build": "npm run build:node && npm run build:server",
"rebuild": "npm run rebuild:node && npm run rebuild:server",
"build:node": "tsc -b",
"build:server": "cd espresso-server && ./gradlew assembleAndroidTest || cd ..",
"build:server": "cd espresso-server && ./gradlew :app:assembleAndroidTest || cd ..",
"rebuild:node": "npm run clean:node && npm run build:node",
"rebuild:server": "cd espresso-server && ./gradlew clean assembleAndroidTest || cd ..",
"rebuild:server": "cd espresso-server && ./gradlew clean :app:assembleAndroidTest || cd ..",
"clean:node": "npm run build -- --clean",
"clean:server": "cd espresso-server && ./gradlew clean || cd ..",
"dev": "npm run build -- --watch",
Expand Down

0 comments on commit 040ba39

Please sign in to comment.