diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2022-11-05 11:14:20 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2022-11-05 11:14:20 +0100 |
| commit | 7daade1c4d3756e67fe14c87d5212f0c9f77205c (patch) | |
| tree | 24030f9b373b3d110a641e3f3e68a43ab47d6436 /src/main/groovy/FlycheckAndroidKotlinTask.groovy | |
| parent | b3467614c5917a1c24afa30ae9101984f09a0b0b (diff) | |
Add support for kotlin by adding flycheck-android-kotlin checker
Diffstat (limited to 'src/main/groovy/FlycheckAndroidKotlinTask.groovy')
| -rw-r--r-- | src/main/groovy/FlycheckAndroidKotlinTask.groovy | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/main/groovy/FlycheckAndroidKotlinTask.groovy b/src/main/groovy/FlycheckAndroidKotlinTask.groovy new file mode 100644 index 0000000..df5856d --- /dev/null +++ b/src/main/groovy/FlycheckAndroidKotlinTask.groovy @@ -0,0 +1,65 @@ +package org.thejk + +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.compile.JavaCompile + +class FlycheckAndroidKotlinTask extends DefaultTask { + FlycheckAndroidKotlinTask() { + } + + @TaskAction + def action() { + def variants = [] + def android = project.extensions.findByName('android') + if (android && (android.class.simpleName == 'AppExtension_Decorated' + || android.class.simpleName == 'BaseAppModuleExtension_Decorated')) { + variants = android.applicationVariants.collect { it.name } + } else if (android && android.class.simpleName == 'LibraryExtension_Decorated') { + variants = android.libraryVariants.collect { it.name } + } else { + def buildTypes = project.extensions.buildTypes.names + if (buildTypes.isEmpty()) buildTypes = ['debug', 'release'] + def flavors = project.extensions.flavors.names + if (flavors.isEmpty()) { + variants = buildTypes + } else { + flavors.each { flavor -> + buildTypes.each { buildType -> + variants.add(flavor + buildType.capitalize()) + } + } + } + } + variants = variants.sort() + def configurations = ['', 'UnitTest'] + variants.each { variant -> + configurations.each { configuration -> + def name = 'compile' + name += variant.capitalize() + name += configuration.capitalize() + 'Kotlin' + def compile = project.tasks.findByName(name) + if (compile) { + try { + def cp = compile.classpath.asPath + println '***' + println 'variant=' + variant + println 'args=' + compile.defaultSerializedCompilerArguments + println 'cp=' + cp + println 'files=' + compile.inputs.files.asPath + println 'output=' + compile.destinationDirectory.get() + } catch (Throwable t) { + } + } + } + + def name = 'generate' + name += variant.capitalize() + 'Sources' + def generate = project.tasks.findByName(name) + if (generate != null) { + println '!!!' + println generate.path + } + } + } +} |
