diff --git a/MODULE.bazel b/MODULE.bazel index 8f274e9..cdd6dc4 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,7 +6,7 @@ module( bazel_dep(name = "rules_java", version = "8.6.3") bazel_dep(name = "rules_jvm_external", version = "5.3") -bazel_dep(name = "rules_kotlin", version = "1.9.5") +bazel_dep(name = "rules_kotlin", version = "2.1.0") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "platforms", version = "0.0.8") diff --git a/src/cli/AndroidLintAction.kt b/src/cli/AndroidLintAction.kt index a92a216..47addfe 100644 --- a/src/cli/AndroidLintAction.kt +++ b/src/cli/AndroidLintAction.kt @@ -6,7 +6,6 @@ import java.nio.file.Files import kotlin.system.exitProcess object AndroidLintAction { - @JvmStatic fun main(args: Array) { val worker = Worker.fromArgs(args, AndroidLintExecutor()) @@ -15,7 +14,10 @@ object AndroidLintAction { } private class AndroidLintExecutor : Worker.WorkRequestCallback { - override fun processWorkRequest(args: List, printStream: PrintStream): Int { + override fun processWorkRequest( + args: List, + printStream: PrintStream, + ): Int { val workingDirectory = Files.createTempDirectory("rules") try { diff --git a/src/cli/AndroidLintActionArgs.kt b/src/cli/AndroidLintActionArgs.kt index bfbb427..84d6669 100644 --- a/src/cli/AndroidLintActionArgs.kt +++ b/src/cli/AndroidLintActionArgs.kt @@ -10,7 +10,6 @@ import java.nio.file.Paths internal class AndroidLintActionArgs( parser: ArgParser, ) { - private val argsParserPathTransformer: String.() -> Path = { Paths.get(this) } @@ -26,10 +25,11 @@ internal class AndroidLintActionArgs( help = "", ) - val androidHome: String? by parser.storing( - names = arrayOf("--android-home"), - help = "The relative location of Android home", - ).default { null } + val androidHome: String? by parser + .storing( + names = arrayOf("--android-home"), + help = "The relative location of Android home", + ).default { null } val srcs: List by parser.adding( names = arrayOf("--src"), @@ -43,66 +43,77 @@ internal class AndroidLintActionArgs( transform = argsParserPathTransformer, ) - val resources: List by parser.adding( - names = arrayOf("--resource"), - help = "", - transform = argsParserPathTransformer, - ).default { emptyList() } - - val androidManifest: Path? by parser.storing( - names = arrayOf("--android-manifest"), - help = "", - transform = argsParserPathTransformer, - ).default { null } - - val baselineFile: Path? by parser.storing( - names = arrayOf("--baseline-file"), - help = "", - transform = argsParserPathTransformer, - ).default { null } - - val config: Path? by parser.storing( - names = arrayOf("--config-file"), - help = "", - transform = argsParserPathTransformer, - ).default { null } - - val customChecks: List by parser.adding( - names = arrayOf("--custom-rule"), - help = "", - transform = argsParserPathTransformer, - ).default { emptyList() } - - val classpath: List by parser.adding( - names = arrayOf("--classpath"), - help = "", - transform = argsParserPathTransformer, - ).default { emptyList() } - - val autofix: Boolean by parser.flagging( - names = arrayOf("--autofix"), - help = "TODO Not supported yet", - ).default { false } - - val regenerateBaselineFile: Boolean by parser.flagging( - names = arrayOf("--regenerate-baseline-files"), - help = "", - ).default { false } - - val warningsAsErrors: Boolean by parser.flagging( - names = arrayOf("--warnings-as-errors"), - help = "", - ).default { false } - - val enableChecks: List by parser.adding( - names = arrayOf("--enable-check"), - help = "", - ).default { emptyList() } - - val disableChecks: List by parser.adding( - names = arrayOf("--disable-check"), - help = "", - ).default { emptyList() } + val resources: List by parser + .adding( + names = arrayOf("--resource"), + help = "", + transform = argsParserPathTransformer, + ).default { emptyList() } + + val androidManifest: Path? by parser + .storing( + names = arrayOf("--android-manifest"), + help = "", + transform = argsParserPathTransformer, + ).default { null } + + val baselineFile: Path? by parser + .storing( + names = arrayOf("--baseline-file"), + help = "", + transform = argsParserPathTransformer, + ).default { null } + + val config: Path? by parser + .storing( + names = arrayOf("--config-file"), + help = "", + transform = argsParserPathTransformer, + ).default { null } + + val customChecks: List by parser + .adding( + names = arrayOf("--custom-rule"), + help = "", + transform = argsParserPathTransformer, + ).default { emptyList() } + + val classpath: List by parser + .adding( + names = arrayOf("--classpath"), + help = "", + transform = argsParserPathTransformer, + ).default { emptyList() } + + val autofix: Boolean by parser + .flagging( + names = arrayOf("--autofix"), + help = "TODO Not supported yet", + ).default { false } + + val regenerateBaselineFile: Boolean by parser + .flagging( + names = arrayOf("--regenerate-baseline-files"), + help = "", + ).default { false } + + val warningsAsErrors: Boolean by parser + .flagging( + names = arrayOf("--warnings-as-errors"), + help = "", + ).default { false } + + val enableChecks: List by parser + .adding( + names = arrayOf("--enable-check"), + help = "", + ).default { emptyList() } + + val disableChecks: List by parser + .adding( + names = arrayOf("--disable-check"), + help = "", + ).default { emptyList() } val compileSdkVersion: String by parser.storing( names = arrayOf("--compile-sdk-version"), @@ -119,20 +130,21 @@ internal class AndroidLintActionArgs( help = "", ) - val enableCheckDependencies: Boolean by parser.flagging( - names = arrayOf("--enable-check-dependencies"), - help = "", - ).default { false } + val enableCheckDependencies: Boolean by parser + .flagging( + names = arrayOf("--enable-check-dependencies"), + help = "", + ).default { false } companion object { - internal fun parseArgs(args: List): AndroidLintActionArgs { // TODO Need to handle the --flagfile argument here - val unwrappedArgs: Array = if (args.size == 1 && args[0].startsWith("@")) { - File(args[0].removePrefix("@")).readLines(Charset.defaultCharset()).toTypedArray() - } else { - args.toTypedArray() - } + val unwrappedArgs: Array = + if (args.size == 1 && args[0].startsWith("@")) { + File(args[0].removePrefix("@")).readLines(Charset.defaultCharset()).toTypedArray() + } else { + args.toTypedArray() + } return AndroidLintActionArgs(ArgParser(unwrappedArgs)) } diff --git a/src/cli/AndroidLintCliInvoker.kt b/src/cli/AndroidLintCliInvoker.kt index cd0d891..0c87926 100644 --- a/src/cli/AndroidLintCliInvoker.kt +++ b/src/cli/AndroidLintCliInvoker.kt @@ -10,15 +10,18 @@ import kotlin.io.path.pathString class AndroidLintCliInvoker( classLoader: ClassLoader, ) { - private val mainClass = Class.forName("com.android.tools.lint.Main", true, classLoader) private val cliFlags = classLoader.loadClass("com.android.tools.lint.LintCliFlags") - private val mainInstance = mainClass - .getDeclaredConstructor() - .newInstance() - private val flagsInstance = mainClass.getDeclaredField("flags").apply { - isAccessible = true - }.get(mainInstance) + private val mainInstance = + mainClass + .getDeclaredConstructor() + .newInstance() + private val flagsInstance = + mainClass + .getDeclaredField("flags") + .apply { + isAccessible = true + }.get(mainInstance) /* * Exit Status: @@ -37,15 +40,15 @@ class AndroidLintCliInvoker( } fun setCheckDependencies(enableCheckDependencies: Boolean) { - val setCheckDependenciesMethod = cliFlags.getDeclaredMethod( - "setCheckDependencies", - Boolean::class.java, - ) + val setCheckDependenciesMethod = + cliFlags.getDeclaredMethod( + "setCheckDependencies", + Boolean::class.java, + ) setCheckDependenciesMethod.invoke(flagsInstance, enableCheckDependencies) } companion object { - const val ERRNO_SUCCESS = 0 const val ERRNO_ERRORS = 1 const val ERRNO_USAGE = 2 @@ -64,12 +67,14 @@ class AndroidLintCliInvoker( "Error: At least one jar must be provided when calling createUsingJars" } - val classpath = jars.map { jar -> - require(jar.isRegularFile() && jar.exists()) { - "Error: The provided jar does not exist!: ${jar.pathString}" - } - URL("file:${jar.pathString}") - }.toTypedArray() + val classpath = + jars + .map { jar -> + require(jar.isRegularFile() && jar.exists()) { + "Error: The provided jar does not exist!: ${jar.pathString}" + } + URL("file:${jar.pathString}") + }.toTypedArray() return AndroidLintCliInvoker(classLoader = URLClassLoader(classpath, parentClassloader)) } diff --git a/src/cli/AndroidLintProject.kt b/src/cli/AndroidLintProject.kt index ec13328..eb1a239 100644 --- a/src/cli/AndroidLintProject.kt +++ b/src/cli/AndroidLintProject.kt @@ -31,13 +31,14 @@ internal fun createProjectXMLString( projectElement.appendChild(it) } - val moduleElement = document.createElement("module").also { - it.setAttribute("name", moduleName) - it.setAttribute("android", if (androidManifest != null) "true" else "false") - // it.setAttribute("library", "false") - // it.setAttribute("compile-sdk-version", "get-actual-value-here") - projectElement.appendChild(it) - } + val moduleElement = + document.createElement("module").also { + it.setAttribute("name", moduleName) + it.setAttribute("android", if (androidManifest != null) "true" else "false") + // it.setAttribute("library", "false") + // it.setAttribute("compile-sdk-version", "get-actual-value-here") + projectElement.appendChild(it) + } customLintChecks.forEach { jar -> document.createElement("lint-checks").also { @@ -83,10 +84,12 @@ internal fun createProjectXMLString( moduleElement.appendChild(element) } - return StringWriter().apply { - val transformer = TransformerFactory.newInstance().newTransformer() - transformer.setOutputProperty(OutputKeys.INDENT, "yes") - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2") - transformer.transform(DOMSource(document), StreamResult(this)) - }.buffer.toString() + return StringWriter() + .apply { + val transformer = TransformerFactory.newInstance().newTransformer() + transformer.setOutputProperty(OutputKeys.INDENT, "yes") + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2") + transformer.transform(DOMSource(document), StreamResult(this)) + }.buffer + .toString() } diff --git a/src/cli/AndroidLintRunner.kt b/src/cli/AndroidLintRunner.kt index 4d9638f..dcdac10 100644 --- a/src/cli/AndroidLintRunner.kt +++ b/src/cli/AndroidLintRunner.kt @@ -15,7 +15,6 @@ import kotlin.io.path.pathString import kotlin.io.path.writeText internal class AndroidLintRunner { - internal fun runAndroidLint( args: AndroidLintActionArgs, workingDirectory: Path, @@ -37,10 +36,11 @@ internal class AndroidLintRunner { val unpackedAars = unpackAars(aars, workingDirectory.resolve("aars")) // Collect the custom lint rules from the unpacked aars - val aarLintRuleJars = unpackedAars - .asSequence() - .map { it.first.resolve("lint.jar") } - .filter { it.exists() && it.isRegularFile() } + val aarLintRuleJars = + unpackedAars + .asSequence() + .map { it.first.resolve("lint.jar") } + .filter { it.exists() && it.isRegularFile() } // Create the project configuration file for lint val projectFile = workingDirectory.resolve("${args.label}_project_config.xml") @@ -65,14 +65,15 @@ internal class AndroidLintRunner { val androidCacheFolder = workingDirectory.resolve("android-cache") Files.createDirectory(androidCacheFolder) val invoker = AndroidLintCliInvoker.createUsingJars(jars = arrayOf(args.androidLintCliTool)) - val exitCode = invokeAndroidLintCLI( - invoker = invoker, - actionArgs = args, - rootDirPath = rootDir, - projectFilePath = projectFile, - baselineFilePath = baselineFile, - cacheDirectoryPath = androidCacheFolder, - ) + val exitCode = + invokeAndroidLintCLI( + invoker = invoker, + actionArgs = args, + rootDirPath = rootDir, + projectFilePath = projectFile, + baselineFilePath = baselineFile, + cacheDirectoryPath = androidCacheFolder, + ) return when (exitCode) { AndroidLintCliInvoker.ERRNO_SUCCESS, @@ -91,30 +92,32 @@ internal class AndroidLintRunner { baselineFilePath: Path, cacheDirectoryPath: Path, ): Int { - val args = mutableListOf( - "--project", - projectFilePath.pathString, - "--xml", - actionArgs.output.pathString, - "--path-variables", - "PWD=$rootDirPath", - "--exitcode", - "--compile-sdk-version", - actionArgs.compileSdkVersion, - "--java-language-level", - actionArgs.javaLanguageLevel, - "--kotlin-language-level", - actionArgs.kotlinLanguageLevel, - "--stacktrace", - "--quiet", - "--offline", - "--baseline", - baselineFilePath.pathString, - "--update-baseline", - "--cache-dir", - cacheDirectoryPath.pathString, - "--client-id", "cli", - ) + val args = + mutableListOf( + "--project", + projectFilePath.pathString, + "--xml", + actionArgs.output.pathString, + "--path-variables", + "PWD=$rootDirPath", + "--exitcode", + "--compile-sdk-version", + actionArgs.compileSdkVersion, + "--java-language-level", + actionArgs.javaLanguageLevel, + "--kotlin-language-level", + actionArgs.kotlinLanguageLevel, + "--stacktrace", + "--quiet", + "--offline", + "--baseline", + baselineFilePath.pathString, + "--update-baseline", + "--cache-dir", + cacheDirectoryPath.pathString, + "--client-id", + "cli", + ) if (actionArgs.warningsAsErrors) { args.add("-Werror") } else { diff --git a/src/cli/AndroidLintWrapperUtils.kt b/src/cli/AndroidLintWrapperUtils.kt index a23ec29..9aa1faf 100644 --- a/src/cli/AndroidLintWrapperUtils.kt +++ b/src/cli/AndroidLintWrapperUtils.kt @@ -5,7 +5,10 @@ import java.nio.file.Path import java.util.zip.ZipInputStream import kotlin.io.path.inputStream -internal fun unzip(src: Path, dst: Path) { +internal fun unzip( + src: Path, + dst: Path, +) { val dstFile = dst.toFile() val bufferedZipInputStream = src.inputStream().buffered() ZipInputStream(bufferedZipInputStream).use { zipStream -> @@ -14,7 +17,9 @@ internal fun unzip(src: Path, dst: Path) { if (zipEntry.isDirectory) { File(dstFile, zipEntry.name).mkdirs() } else { - File(dstFile, zipEntry.name).also { it.parentFile.mkdirs() }.outputStream() + File(dstFile, zipEntry.name) + .also { it.parentFile.mkdirs() } + .outputStream() .use { fileOutputStream -> zipStream.copyTo(fileOutputStream) } } diff --git a/src/worker/InvocationWorker.kt b/src/worker/InvocationWorker.kt index 631e928..4fd8ca7 100644 --- a/src/worker/InvocationWorker.kt +++ b/src/worker/InvocationWorker.kt @@ -4,7 +4,6 @@ internal class InvocationWorker( private val args: Array, private val workerMessageProcessor: Worker.WorkRequestCallback, ) : Worker { - override fun processRequests(): Int { // Handle a single work request return workerMessageProcessor.processWorkRequest(args.toList(), System.err) diff --git a/src/worker/PersistentWorker.kt b/src/worker/PersistentWorker.kt index 794bd43..9681426 100644 --- a/src/worker/PersistentWorker.kt +++ b/src/worker/PersistentWorker.kt @@ -14,38 +14,34 @@ internal class PersistentWorker( * WorkerIO instance wrapping the standard output streams */ private val workerIO: WorkerIO, - /** * Rxjava Scheduler to execute work requests on. */ private val scheduler: Scheduler, - /** * Instance of CpuTimeBasedGcScheduler that will run periodically */ private val persistentWorkerCpuTimeBasedGcScheduler: PersistentWorkerCpuTimeBasedGcScheduler, - /** * Instance of CpuTimeBasedGcScheduler that will run periodically */ private val workRequestProcessor: Worker.WorkerMessageProcessor, - /** * Instance of CpuTimeBasedGcScheduler that will run periodically */ private val workerWorkRequestCallback: Worker.WorkRequestCallback, ) : Worker { - constructor( workerMessageProcessor: Worker.WorkRequestCallback, ) : this( workerIO = WorkerIO(), scheduler = Schedulers.io(), persistentWorkerCpuTimeBasedGcScheduler = PersistentWorkerCpuTimeBasedGcScheduler(), - workRequestProcessor = WorkerJsonMessageProcessor( - System.`in`, - System.out, - ), + workRequestProcessor = + WorkerJsonMessageProcessor( + System.`in`, + System.out, + ), workerWorkRequestCallback = workerMessageProcessor, ) @@ -59,24 +55,29 @@ internal class PersistentWorker( io.redirectSystemStreams() // Process requests as they come in using RxJava - Flowable.create( - { emitter -> - while (!emitter.isCancelled) { - try { - val request: WorkRequest = workRequestProcessor.readWorkRequest() - emitter.onNext(request) - } catch (e: IOException) { - emitter.onError(e) + Flowable + .create( + { emitter -> + while (!emitter.isCancelled) { + try { + val request: WorkRequest = workRequestProcessor.readWorkRequest() + emitter.onNext(request) + } catch (e: IOException) { + emitter.onError(e) + } } - } - }, - BackpressureStrategy.BUFFER, - ).subscribeOn(scheduler).parallel().runOn(scheduler) + }, + BackpressureStrategy.BUFFER, + ).subscribeOn(scheduler) + .parallel() + .runOn(scheduler) // Execute the work and map the result to a work response .map { request -> return@map this.respondToRequest(request) } // Run the garbage collector periodically so that we are a good responsible worker .doOnNext { persistentWorkerCpuTimeBasedGcScheduler.maybePerformGc() } - .doOnError { it.printStackTrace() }.sequential().observeOn(scheduler) + .doOnError { it.printStackTrace() } + .sequential() + .observeOn(scheduler) .blockingSubscribe { response -> workRequestProcessor.writeWorkResponse(response) } @@ -108,11 +109,12 @@ internal class PersistentWorker( printStream.flush() } - val output = arrayOf(baos.toString()) - .asSequence() - .map { it.trim() } - .filter { it.isNotEmpty() } - .joinToString("\n") + val output = + arrayOf(baos.toString()) + .asSequence() + .map { it.trim() } + .filter { it.isNotEmpty() } + .joinToString("\n") return WorkResponse( exitCode = exitCode, output = output, diff --git a/src/worker/PersistentWorkerCpuTimeBasedGcScheduler.kt b/src/worker/PersistentWorkerCpuTimeBasedGcScheduler.kt index 3290e4a..6f28987 100644 --- a/src/worker/PersistentWorkerCpuTimeBasedGcScheduler.kt +++ b/src/worker/PersistentWorkerCpuTimeBasedGcScheduler.kt @@ -12,7 +12,6 @@ internal class PersistentWorkerCpuTimeBasedGcScheduler( */ private val cpuUsageBeforeGc: Duration = Duration.ofSeconds(10), ) { - private val cpuTime: Duration get() = if (!cpuUsageBeforeGc.isZero) Duration.ofNanos(bean.processCpuTime) else Duration.ZERO diff --git a/src/worker/WorkRequest.kt b/src/worker/WorkRequest.kt index 7cc49a4..4abc54e 100644 --- a/src/worker/WorkRequest.kt +++ b/src/worker/WorkRequest.kt @@ -8,7 +8,6 @@ data class WorkRequest( */ @Json(name = "requestId") val requestId: Int = 0, - /** * The work request arguments */ diff --git a/src/worker/WorkResponse.kt b/src/worker/WorkResponse.kt index 418d5a3..6c9045f 100644 --- a/src/worker/WorkResponse.kt +++ b/src/worker/WorkResponse.kt @@ -8,13 +8,11 @@ data class WorkResponse( */ @Json(name = "requestId") val requestId: Int, - /** * Exit status for the work request */ @Json(name = "exitCode") val exitCode: Int, - /** * Standard output that was collected during the work request */ diff --git a/src/worker/Worker.kt b/src/worker/Worker.kt index f009f01..ca81694 100644 --- a/src/worker/Worker.kt +++ b/src/worker/Worker.kt @@ -4,19 +4,19 @@ import java.io.IOException import java.io.PrintStream interface Worker { - fun processRequests(): Int interface WorkRequestCallback { - /** * Processes an individual work request. */ - fun processWorkRequest(args: List, printStream: PrintStream): Int + fun processWorkRequest( + args: List, + printStream: PrintStream, + ): Int } interface WorkerMessageProcessor { - @Throws(IOException::class) fun readWorkRequest(): WorkRequest @@ -25,7 +25,6 @@ interface Worker { } companion object { - /** * Creates the appropriate worker instance using the provided worker arguments. * @@ -35,11 +34,10 @@ interface Worker { fun fromArgs( args: Array, workerMessageProcessor: WorkRequestCallback, - ): Worker { - return when { + ): Worker = + when { "--persistent_worker" in args -> PersistentWorker(workerMessageProcessor) else -> InvocationWorker(args, workerMessageProcessor) } - } } } diff --git a/src/worker/WorkerIO.kt b/src/worker/WorkerIO.kt index 159a662..df4f4dc 100644 --- a/src/worker/WorkerIO.kt +++ b/src/worker/WorkerIO.kt @@ -8,7 +8,6 @@ internal class WorkerIO( val output: PrintStream = System.out, val err: PrintStream = System.err, ) : AutoCloseable { - fun redirectSystemStreams(): WorkerIO { System.setOut(err) return this diff --git a/src/worker/WorkerJsonMessageProcessor.kt b/src/worker/WorkerJsonMessageProcessor.kt index 6d530c2..b6e881c 100644 --- a/src/worker/WorkerJsonMessageProcessor.kt +++ b/src/worker/WorkerJsonMessageProcessor.kt @@ -15,7 +15,6 @@ class WorkerJsonMessageProcessor( inputStream: InputStream, outputStream: OutputStream, ) : Worker.WorkerMessageProcessor { - // Moshi JSON type adapters private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build() private val workRequestAdapter: JsonAdapter = moshi.adapter(WorkRequest::class.java) diff --git a/tests/src/cli/AndroidLintActionArgsTest.kt b/tests/src/cli/AndroidLintActionArgsTest.kt index 01e77e9..a82b789 100644 --- a/tests/src/cli/AndroidLintActionArgsTest.kt +++ b/tests/src/cli/AndroidLintActionArgsTest.kt @@ -8,49 +8,50 @@ import java.nio.file.Paths @RunWith(JUnit4::class) class AndroidLintActionArgsTest { - @Test fun `does parse all arguments`() { - val parseArgs = AndroidLintActionArgs.parseArgs( - args = listOf( - "--label", - "test", - "--android-lint-cli-tool", - "path/to/cli.jar", - "--src", - "path/to/Foo.kt", - "--output", - "output.jar", - "--resource", - "path/to/resource/strings.xml", - "--android-manifest", - "AndroidManifest.xml", - "--baseline-file", - "lib_lint_baseline.xml", - "--config-file", - "lint_config.xml", - "--custom-rule", - "custom_rule.jar", - "--classpath", - "classpath.jar", - "--classpath", - "classpath.aar", - "--autofix", - "--regenerate-baseline-files", - "--warnings-as-errors", - "--enable-check", - "custom-check", - "--disable-check", - "custom-disabled-check", - "--compile-sdk-version", - "1.6", - "--java-language-level", - "1.7", - "--kotlin-language-level", - "1.8", - "--enable-check-dependencies", - ), - ) + val parseArgs = + AndroidLintActionArgs.parseArgs( + args = + listOf( + "--label", + "test", + "--android-lint-cli-tool", + "path/to/cli.jar", + "--src", + "path/to/Foo.kt", + "--output", + "output.jar", + "--resource", + "path/to/resource/strings.xml", + "--android-manifest", + "AndroidManifest.xml", + "--baseline-file", + "lib_lint_baseline.xml", + "--config-file", + "lint_config.xml", + "--custom-rule", + "custom_rule.jar", + "--classpath", + "classpath.jar", + "--classpath", + "classpath.aar", + "--autofix", + "--regenerate-baseline-files", + "--warnings-as-errors", + "--enable-check", + "custom-check", + "--disable-check", + "custom-disabled-check", + "--compile-sdk-version", + "1.6", + "--java-language-level", + "1.7", + "--kotlin-language-level", + "1.8", + "--enable-check-dependencies", + ), + ) assertThat(parseArgs.label).isEqualTo("test") assertThat(parseArgs.srcs).containsExactly(Paths.get("path/to/Foo.kt")) diff --git a/tests/src/cli/AndroidLintProjectTest.kt b/tests/src/cli/AndroidLintProjectTest.kt index 2fd4e89..824c4c9 100644 --- a/tests/src/cli/AndroidLintProjectTest.kt +++ b/tests/src/cli/AndroidLintProjectTest.kt @@ -10,7 +10,6 @@ import java.nio.file.Path @RunWith(JUnit4::class) class AndroidLintProjectTest { - @Rule @JvmField var tmpDirectory = TemporaryFolder() @@ -28,12 +27,13 @@ class AndroidLintProjectTest { androidManifest = tmpDirectory.newPath("AndroidManifest.xml"), classpathJars = listOf(tmpDirectory.newPath("Foo.jar")), classpathAars = listOf(tmpDirectory.newPath("Foo.aar")), - classpathExtractedAarDirectories = listOf( - Pair( - tmpDirectory.newPath("Bar.aar"), - tmpDirectory.newFolder("tmp/unpacked_aars/bar/").toPath(), + classpathExtractedAarDirectories = + listOf( + Pair( + tmpDirectory.newPath("Bar.aar"), + tmpDirectory.newFolder("tmp/unpacked_aars/bar/").toPath(), + ), ), - ), customLintChecks = listOf(tmpDirectory.newPath("tmp/unpacked_aars/bar/lint.jar")), ), ).isEqualTo(