Skip to content

Commit

Permalink
ktlint 12.1.1 (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsburrows authored Aug 1, 2024
1 parent ee43b25 commit a63827b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.time.format.DateTimeFormatter
plugins {
id 'org.jetbrains.kotlin.jvm' version '2.0.0'
id 'org.jetbrains.dokka' version '1.9.20' apply false
id 'org.jlleitschuh.gradle.ktlint' version '11.6.1' apply false
id 'org.jlleitschuh.gradle.ktlint' version '12.1.1' apply false
id 'com.vanniktech.maven.publish' version '0.25.3' apply false
id 'com.gradle.plugin-publish' version '0.21.0' apply false
id 'com.github.ben-manes.versions' version '0.51.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ private fun Project.configureVariant(
) {
// Configure tasks for all variants
variants?.all { variant ->
val name = variant.name.replaceFirstChar {
if (it.isLowerCase()) {
it.titlecase(Locale.getDefault())
} else {
it.toString()
val name =
variant.name.replaceFirstChar {
if (it.isLowerCase()) {
it.titlecase(Locale.getDefault())
} else {
it.toString()
}
}
}

// Create tasks based on variant
tasks.register("spoon$name", SpoonTask::class.java) {
Expand All @@ -70,8 +71,9 @@ private fun Project.configureVariant(
}

it.spoonExtension = project.extensions.getByType(SpoonExtension::class.java)
it.outputDir = project.extensions.getByType(ReportingExtension::class.java)
.file(SpoonExtension.DEFAULT_OUTPUT_DIRECTORY)
it.outputDir =
project.extensions.getByType(ReportingExtension::class.java)
.file(SpoonExtension.DEFAULT_OUTPUT_DIRECTORY)
it.buildDir = project.buildDir

it.testing = project.isNotTest()
Expand All @@ -82,11 +84,12 @@ private fun Project.configureVariant(
val testedOutput = variant.testedVariant.outputs.first()
// This is a hack for library projects.
// We supply the same apk as an application and instrumentation to the soon runner.
it.applicationApk = if (testedOutput is ApkVariantOutput) {
testedOutput.outputFile
} else {
instrumentationApk
}
it.applicationApk =
if (testedOutput is ApkVariantOutput) {
testedOutput.outputFile
} else {
instrumentationApk
}

it.sdkDirectory = baseExtension.sdkDirectory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jaredsburrows.spoon

/**
* Configuration options for the gradle spoon plugin.
* Configuration options for the gradle spoon plugin. Supported directly by Spoon's SpoonRunner.
*
* Variables based on the following documentation:
* - https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html
Expand All @@ -10,7 +10,6 @@ package com.jaredsburrows.spoon
* - https://github.com/square/spoon#execution
*/
open class SpoonExtension { // extensions cannot be final
/* Supported directly by Spoon's SpoonRunner */

/** Identifying title for this execution. ("Spoon Execution" by default) */
var title: String = DEFAULT_TITLE
Expand Down Expand Up @@ -77,7 +76,7 @@ open class SpoonExtension { // extensions cannot be final
/** Run 'pm clear' before each test to clear app data before each test. */
var clearAppDataBeforeEachTest: Boolean = false

/* Passed in via -e, extra arguments */
// Passed in via -e, extra arguments

/** The number of separate shards to create. */
var numShards: Int = 0
Expand All @@ -94,7 +93,7 @@ open class SpoonExtension { // extensions cannot be final
/** Do not fail build if a test fails, let all the tests run and finish. (false by default) */
var ignoreFailures: Boolean = false

/* Deprecated/Renamed */
// Deprecated/Renamed

@Deprecated("Use 'grantAll'", replaceWith = ReplaceWith("grantAll"))
var grantAllPermissions: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.gradle.api.Project

/** A [Plugin] which wraps the Spoon test runner. */
class SpoonPlugin : Plugin<Project> {

override fun apply(project: Project) {
project.extensions.create("spoon", SpoonExtension::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,23 @@ open class SpoonTask : DefaultTask() { // tasks can't be final
}
outputDir = File(outputBase, variantName)

val builder = SpoonRunner.Builder()
.setTitle(spoonExtension.title)
.setOutputDirectory(outputDir)
.setDebug(spoonExtension.debug)
.setNoAnimations(spoonExtension.noAnimations)
.setAdbTimeout(Duration.ofSeconds(spoonExtension.adbTimeout.toLong()))
.setClassName(spoonExtension.className)
.setAllowNoDevices(spoonExtension.allowNoDevices)
.setSequential(spoonExtension.sequential)
.setGrantAll(spoonExtension.grantAll)
.setMethodName(spoonExtension.methodName)
.setCodeCoverage(spoonExtension.codeCoverage)
.setShard(spoonExtension.shard)
.setTerminateAdb(false)
.setSingleInstrumentationCall(spoonExtension.singleInstrumentationCall)
.setClearAppDataBeforeEachTest(spoonExtension.clearAppDataBeforeEachTest)
val builder =
SpoonRunner.Builder()
.setTitle(spoonExtension.title)
.setOutputDirectory(outputDir)
.setDebug(spoonExtension.debug)
.setNoAnimations(spoonExtension.noAnimations)
.setAdbTimeout(Duration.ofSeconds(spoonExtension.adbTimeout.toLong()))
.setClassName(spoonExtension.className)
.setAllowNoDevices(spoonExtension.allowNoDevices)
.setSequential(spoonExtension.sequential)
.setGrantAll(spoonExtension.grantAll)
.setMethodName(spoonExtension.methodName)
.setCodeCoverage(spoonExtension.codeCoverage)
.setShard(spoonExtension.shard)
.setTerminateAdb(false)
.setSingleInstrumentationCall(spoonExtension.singleInstrumentationCall)
.setClearAppDataBeforeEachTest(spoonExtension.clearAppDataBeforeEachTest)

// APKs
if (testing) {
Expand Down Expand Up @@ -100,11 +101,12 @@ open class SpoonTask : DefaultTask() { // tasks can't be final
throw UnsupportedOperationException("Please use '=' or ':' to separate arguments.")
}

val keyVal = if (instrumentation.contains(':')) {
instrumentation.split(':')
} else {
instrumentation.split('=')
}
val keyVal =
if (instrumentation.contains(':')) {
instrumentation.split(':')
} else {
instrumentation.split('=')
}
instrumentationArgs[keyVal[0]] = keyVal[1]
}
builder.setInstrumentationArgs(instrumentationArgs)
Expand Down

0 comments on commit a63827b

Please sign in to comment.