-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add adbserver plugin and setup publication (#611)
* remove now stable feature VERSION_CATALOGS definition * move samples as separate project * rename alure && compose modules with gradle module naming convention * fix .cirrus to run tests form samples * add empty kaspresso plugin && add it to samples * fix cirrus gradlew paths resolution * setup empty start/stop adb server tasks * update desktop to run async * add working directory support for adb server * move test artifacts to sample directory * remove manual start adb server from cirrus * add specify adb server path option for desktop server * fix detekt * add gradle logger * add documentation to Desktop.kt && fix pattern compile at every getAttachedDevicesByAdb function call * add adb path resolution && logging * setup gradle plugin portal publishing * fix build error * fix detekt * move allure support files back where they should be * fix build * temporarily remove unknown props for api 30 tests * try fix api 30 tests * fix gradle sync for samples * more test fixes --------- Co-authored-by: Vladislav Sumin <vladislav.sumin@kaspersky.com>
- Loading branch information
1 parent
69ddba1
commit df165a9
Showing
71 changed files
with
715 additions
and
46 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
21 changes: 21 additions & 0 deletions
21
...er/adbserver-desktop/src/main/java/com/kaspersky/adbserver/desktop/AdbCommandPerformer.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,21 @@ | ||
package com.kaspersky.adbserver.desktop | ||
|
||
import com.kaspersky.adbserver.common.api.CommandResult | ||
import java.nio.file.Path | ||
|
||
/** | ||
* @param adbPath - path to adb binary | ||
*/ | ||
class AdbCommandPerformer( | ||
private val adbPath: Path, | ||
private val cmdCommandPerformer: CmdCommandPerformer, | ||
) { | ||
|
||
/** | ||
* Be aware it's a synchronous method | ||
* @param command - adb command without path to adb binaries | ||
*/ | ||
fun perform(command: String): CommandResult { | ||
return cmdCommandPerformer.perform("$adbPath $command") | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
enableFeaturePreview("VERSION_CATALOGS") | ||
|
||
rootProject.name = "build-logic" | ||
|
||
include("android") | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,38 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
`java-gradle-plugin` | ||
id("com.gradle.plugin-publish") version "1.2.1" | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidPlugin) | ||
implementation(projects.adbServer.adbServerCommon) | ||
implementation(projects.adbServer.adbserverDesktop) | ||
} | ||
|
||
group = "com.kaspersky.kaspresso" | ||
version = "1.0" | ||
gradlePlugin { | ||
// TODO: fix for tests on API 30 and uncomment | ||
// website.set("https://kasperskylab.github.io/Kaspresso/en/") | ||
// vcsUrl.set("https://github.com/KasperskyLab/Kaspresso/") | ||
|
||
plugins { | ||
create("AdbServerPlugin") { | ||
id = "com.kaspersky.kaspresso-adb-server-plugin" | ||
displayName = "Kaspresso ADB-server plugin" | ||
description = "Run Kaspresso ADB server for Android UI tests" | ||
// tags.set(listOf("testing", "UI tests", "test automation", "android", "kasresso", "adb server")) | ||
implementationClass = "com.kaspersky.kaspresso.plugin.KaspressoPlugin" | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "localPluginRepository" | ||
url = uri("../local-plugin-repository") | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
kaspresso-plugin/src/main/kotlin/com/kaspersky/kaspresso/plugin/DesktopServerHolder.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,44 @@ | ||
package com.kaspersky.kaspresso.plugin | ||
|
||
import com.kaspersky.adbserver.common.log.LoggerFactory | ||
import com.kaspersky.adbserver.common.log.logger.LogLevel | ||
import com.kaspersky.adbserver.desktop.AdbCommandPerformer | ||
import com.kaspersky.adbserver.desktop.CmdCommandPerformer | ||
import com.kaspersky.adbserver.desktop.Desktop | ||
import org.gradle.api.logging.Logger | ||
import java.nio.file.Path | ||
|
||
internal class DesktopServerHolder(private val logger: Logger) { | ||
companion object { | ||
private const val DESKTOP_NAME = "kaspresso-plugin-adb-server" | ||
} | ||
|
||
private var desktop: Desktop? = null | ||
|
||
@Synchronized | ||
fun start(workingDirectory: Path, adbPath: Path) { | ||
check(desktop == null) { "Desktop already started" } | ||
|
||
logger.debug("Starting Desktop server. workingDir=$workingDirectory, adbPath=$adbPath") | ||
|
||
val cmdCommandPerformer = CmdCommandPerformer(DESKTOP_NAME, workingDirectory) | ||
val adbCommandPerformer = AdbCommandPerformer(adbPath, cmdCommandPerformer) | ||
val logger = LoggerFactory.getDesktopLogger(LogLevel.VERBOSE, DESKTOP_NAME, GradleFullLogger(logger)) | ||
desktop = Desktop( | ||
cmdCommandPerformer = cmdCommandPerformer, | ||
adbCommandPerformer = adbCommandPerformer, | ||
presetEmulators = emptyList(), | ||
adbServerPort = null, | ||
logger = logger, | ||
adbPath = adbPath.toString() | ||
) | ||
.apply { startDevicesObservingAsync() } | ||
} | ||
|
||
@Synchronized | ||
fun stop() { | ||
check(desktop != null) { "Desktop not started" } | ||
desktop!!.stopDevicesObserving() | ||
desktop = null | ||
} | ||
} |
Oops, something went wrong.