Created
May 1, 2021 20:58
-
-
Save k0siara/a86f1aa58cf45f631dbec42e2b6e9b1a to your computer and use it in GitHub Desktop.
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
def appId = "com.patrykkosieradzki.moviebox" | |
android { | |
... | |
defaultConfig { | |
... | |
applicationId appId | |
} | |
} | |
def projectScreenshotsDirectory = "$projectDir/screenshots" | |
def deviceScreenshotsDirectory = '/sdcard/Pictures/' + appId + '/debug/screenshots' | |
def clearScreenshotsTask = task('clearScreenshots', type: Exec) { | |
println deviceScreenshotsDirectory | |
executable "${android.getAdbExe().toString()}" | |
args 'shell', 'rm', '-r', deviceScreenshotsDirectory | |
} | |
def createScreenshotDirectoryTask = task('createScreenshotDirectory', type: Exec, group: 'reporting') { | |
executable "${android.getAdbExe().toString()}" | |
args 'shell', 'mkdir', '-p', deviceScreenshotsDirectory | |
} | |
def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') { | |
executable "${android.getAdbExe().toString()}" | |
args 'pull', deviceScreenshotsDirectory + '/.', projectScreenshotsDirectory | |
finalizedBy { | |
clearScreenshotsTask | |
} | |
dependsOn { | |
createScreenshotDirectoryTask | |
} | |
doFirst { | |
new File(projectScreenshotsDirectory).mkdirs() | |
} | |
} | |
tasks.whenTaskAdded { task -> | |
if (task.name == 'connectedDebugAndroidTest') { | |
task.finalizedBy { | |
fetchScreenshotsTask | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment