Refactoring: cleanup after merge
This commit is contained in:
@@ -35,6 +35,11 @@
|
||||
<artifactId>kotlin-android-extensions</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-gradle-plugin-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
|
||||
+1
-2
@@ -121,7 +121,7 @@ private fun Project.createKotlinAfterJavaTask(
|
||||
}
|
||||
|
||||
class AnnotationProcessingManager(
|
||||
private val task: AbstractCompile,
|
||||
task: AbstractCompile,
|
||||
private val javaTask: JavaCompile,
|
||||
private val taskQualifier: String,
|
||||
private val aptFiles: Set<File>,
|
||||
@@ -130,7 +130,6 @@ class AnnotationProcessingManager(
|
||||
private val androidVariant: Any? = null) {
|
||||
|
||||
private val project = task.project
|
||||
private val random = Random()
|
||||
val wrappersDirectory = File(aptWorkingDir, "wrappers")
|
||||
val hackAnnotationDir = File(aptWorkingDir, "java_src")
|
||||
|
||||
|
||||
+2
-2
@@ -49,7 +49,7 @@ abstract class KotlinSourceSetProcessor<T : AbstractKotlinCompile<*>>(
|
||||
val taskDescription: String
|
||||
) {
|
||||
abstract protected fun doTargetSpecificProcessing()
|
||||
val logger = Logging.getLogger(this.javaClass)
|
||||
protected val logger = Logging.getLogger(this.javaClass)!!
|
||||
|
||||
protected val sourceSetName: String = sourceSet.name
|
||||
protected val sourceRootDir: String = "src/$sourceSetName/kotlin"
|
||||
@@ -179,7 +179,7 @@ class Kotlin2JsSourceSetProcessor(
|
||||
compileTaskNameSuffix = "kotlin2Js"
|
||||
) {
|
||||
override val defaultKotlinDestinationDir: File
|
||||
get() = File(project.buildDir, "kotlin2js/${sourceSetName}")
|
||||
get() = File(project.buildDir, "kotlin2js/$sourceSetName")
|
||||
|
||||
private val clean = project.tasks.findByName("clean")
|
||||
private val build = project.tasks.findByName("build")
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ abstract class TaskToFriendTaskMapper {
|
||||
|
||||
sealed class RegexTaskToFriendTaskMapper(
|
||||
private val prefix: String,
|
||||
private val suffix: String
|
||||
suffix: String
|
||||
) : TaskToFriendTaskMapper() {
|
||||
class Default : RegexTaskToFriendTaskMapper("compile", "TestKotlin")
|
||||
class Android : RegexTaskToFriendTaskMapper("compile", "(Unit|Android)TestKotlin")
|
||||
|
||||
+19
-19
@@ -35,7 +35,7 @@ class AndroidGradleWrapper {
|
||||
androidSourceSet.getJava().srcDir(kotlinDirSet)
|
||||
}
|
||||
|
||||
static def PatternFilterable getResourceFilter(Object androidSourceSet) {
|
||||
static PatternFilterable getResourceFilter(Object androidSourceSet) {
|
||||
def resources = androidSourceSet.getResources()
|
||||
if (resources != null) {
|
||||
return resources.getFilter()
|
||||
@@ -44,12 +44,12 @@ class AndroidGradleWrapper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static def String getVariantName(Object variant) {
|
||||
static String getVariantName(Object variant) {
|
||||
return variant.getBuildType().getName()
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static def AbstractCompile getJavaCompile(Object baseVariantData) {
|
||||
static AbstractCompile getJavaCompile(Object baseVariantData) {
|
||||
if (baseVariantData.getMetaClass().getMetaProperty("javaCompileTask")) {
|
||||
return baseVariantData.javaCompileTask
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class AndroidGradleWrapper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static def Set<File> getJavaSrcDirs(Object androidSourceSet) {
|
||||
static Set<File> getJavaSrcDirs(Object androidSourceSet) {
|
||||
return androidSourceSet.getJava().getSrcDirs()
|
||||
}
|
||||
|
||||
@@ -69,17 +69,17 @@ class AndroidGradleWrapper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static def List<String> getProductFlavorsNames(ApkVariant variant) {
|
||||
static List<String> getProductFlavorsNames(ApkVariant variant) {
|
||||
return variant.getProductFlavors().iterator().collect { it.getName() }
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static def List<AndroidSourceSet> getProductFlavorsSourceSets(BaseExtension extension) {
|
||||
static List<AndroidSourceSet> getProductFlavorsSourceSets(BaseExtension extension) {
|
||||
return extension.productFlavors.iterator().collect { extension.sourceSets.findByName(it.name) }
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static def DefaultDomainObjectSet<TestVariant> getTestVariants(BaseExtension extension) {
|
||||
static DefaultDomainObjectSet<TestVariant> getTestVariants(BaseExtension extension) {
|
||||
if (extension.getMetaClass().getMetaMethod("getTestVariants")) {
|
||||
return extension.getTestVariants()
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class AndroidGradleWrapper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static def List<File> getRClassFolder(BaseVariant variant) {
|
||||
static List<File> getRClassFolder(BaseVariant variant) {
|
||||
def list = new ArrayList<File>()
|
||||
if (variant.getMetaClass().getMetaMethod("getProcessResources")) {
|
||||
list.add(variant.getProcessResources().getSourceOutputDir())
|
||||
@@ -100,17 +100,17 @@ class AndroidGradleWrapper {
|
||||
return list
|
||||
}
|
||||
|
||||
static def VariantManager getVariantDataManager(BasePlugin plugin) {
|
||||
static VariantManager getVariantDataManager(BasePlugin plugin) {
|
||||
return plugin.getVariantManager()
|
||||
}
|
||||
|
||||
static def List<File> getJavaSources(BaseVariantData variantData) {
|
||||
static List<File> getJavaSources(BaseVariantData variantData) {
|
||||
def result = new LinkedHashSet<File>()
|
||||
|
||||
// user sources
|
||||
List<SourceProvider> providers = variantData.variantConfiguration.getSortedSourceProviders();
|
||||
List<SourceProvider> providers = variantData.variantConfiguration.getSortedSourceProviders()
|
||||
for (SourceProvider provider : providers) {
|
||||
result.addAll((provider as AndroidSourceSet).getJava().getSrcDirs());
|
||||
result.addAll((provider as AndroidSourceSet).getJava().getSrcDirs())
|
||||
}
|
||||
|
||||
// generated sources
|
||||
@@ -124,24 +124,24 @@ class AndroidGradleWrapper {
|
||||
}
|
||||
else {
|
||||
if (variantData.scope.getGenerateRClassTask() != null) {
|
||||
result.add(variantData.scope.getRClassSourceOutputDir());
|
||||
result.add(variantData.scope.getRClassSourceOutputDir())
|
||||
}
|
||||
|
||||
if (variantData.scope.getGenerateBuildConfigTask() != null) {
|
||||
result.add(variantData.scope.getBuildConfigSourceOutputDir());
|
||||
result.add(variantData.scope.getBuildConfigSourceOutputDir())
|
||||
}
|
||||
|
||||
if (variantData.scope.getAidlCompileTask() != null) {
|
||||
result.add(variantData.scope.getAidlSourceOutputDir());
|
||||
result.add(variantData.scope.getAidlSourceOutputDir())
|
||||
}
|
||||
|
||||
if (variantData.scope.getGlobalScope().getExtension().getDataBinding().isEnabled()) {
|
||||
result.add(variantData.scope.getClassOutputForDataBinding());
|
||||
result.add(variantData.scope.getClassOutputForDataBinding())
|
||||
}
|
||||
|
||||
if (!variantData.variantConfiguration.getRenderscriptNdkModeEnabled()
|
||||
&& variantData.scope.getRenderscriptCompileTask() != null) {
|
||||
result.add(variantData.scope.getRenderscriptSourceOutputDir());
|
||||
result.add(variantData.scope.getRenderscriptSourceOutputDir())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ class AndroidGradleWrapper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static def Map<File, File> getJarToAarMapping(BaseVariantData variantData) {
|
||||
static Map<File, File> getJarToAarMapping(BaseVariantData variantData) {
|
||||
def jarToLibraryArtifactMap = new HashMap<File, File>()
|
||||
|
||||
def libraries = getVariantLibraryDependencies(variantData)
|
||||
@@ -185,7 +185,7 @@ class AndroidGradleWrapper {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static def Iterable<LibraryDependency> getVariantLibraryDependencies(BaseVariantData variantData) {
|
||||
private static Iterable<LibraryDependency> getVariantLibraryDependencies(BaseVariantData variantData) {
|
||||
def variantDependency = variantData.variantDependency
|
||||
if (variantDependency instanceof DependencyContainer) {
|
||||
// android tools < 2.2
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ internal class GradleIncrementalCacheImpl(targetDataRoot: File, targetOutputDir:
|
||||
}
|
||||
|
||||
operator fun get(sourceFile: File): Collection<File> =
|
||||
storage[sourceFile.absolutePath].orEmpty().map { File(it) }
|
||||
storage[sourceFile.absolutePath].orEmpty().map(::File)
|
||||
|
||||
override fun dumpValue(value: Collection<String>) = value.dumpCollection()
|
||||
|
||||
|
||||
-2
@@ -25,8 +25,6 @@ import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
||||
import org.gradle.api.tasks.incremental.InputFileDetails
|
||||
import org.jetbrains.kotlin.bytecode.AnnotationsRemover
|
||||
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||
import org.jetbrains.kotlin.incremental.md5
|
||||
import org.jetbrains.org.objectweb.asm.*
|
||||
import java.io.*
|
||||
import java.util.*
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
+2
-16
@@ -5,8 +5,6 @@ import org.codehaus.groovy.runtime.MethodClosure
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.api.logging.Logger
|
||||
import org.gradle.api.logging.Logging
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension
|
||||
import org.gradle.api.tasks.SourceTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
@@ -72,9 +70,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCo
|
||||
var javaOutputDir: File? = null
|
||||
var moduleName: String = "${project.name}-${this.name}"
|
||||
|
||||
private val loggerInstance = Logging.getLogger(this.javaClass)
|
||||
override fun getLogger() = loggerInstance
|
||||
|
||||
override fun compile() {
|
||||
assert(false, { "unexpected call to compile()" })
|
||||
}
|
||||
@@ -143,7 +138,7 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
||||
private val additionalClasspath = arrayListOf<File>()
|
||||
private val compileClasspath: Iterable<File>
|
||||
get() = (classpath + additionalClasspath)
|
||||
.filterTo(LinkedHashSet()) { it.exists() }
|
||||
.filterTo(LinkedHashSet(), File::exists)
|
||||
private val kapt2GeneratedSourcesDir: File
|
||||
get() = File(project.buildDir, "generated/source/kapt2")
|
||||
|
||||
@@ -619,6 +614,7 @@ open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArguments>(),
|
||||
get() = kotlinOptions.outputFile
|
||||
|
||||
init {
|
||||
@Suppress("LeakingThis")
|
||||
outputs.file(MethodClosure(this, "getOutputFile"))
|
||||
}
|
||||
|
||||
@@ -656,16 +652,6 @@ open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArguments>(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T: Any> ExtraPropertiesExtension.getOrNull(id: String): T? {
|
||||
try {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return get(id) as? T
|
||||
}
|
||||
catch (e: ExtraPropertiesExtension.UnknownPropertyException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class GradleMessageCollector(val logger: Logger, val outputCollector: OutputItemsCollector? = null) : MessageCollector {
|
||||
private var hasErrors = false
|
||||
|
||||
|
||||
+2
-7
@@ -4,12 +4,7 @@ import org.jetbrains.org.objectweb.asm.*
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.*
|
||||
import java.io.File
|
||||
|
||||
/*
|
||||
This file should be a part of AnnotationProcessingManager in kotlin-gradle-plugin,
|
||||
but org.jetbrains.org.objectweb.asm can't be used there.
|
||||
*/
|
||||
|
||||
public fun generateKotlinAptAnnotation(outputDirectory: File): File {
|
||||
fun generateKotlinAptAnnotation(outputDirectory: File): File {
|
||||
val packageName = "__gen"
|
||||
val className = "KotlinAptAnnotation"
|
||||
val classFqName = "$packageName/$className"
|
||||
@@ -30,7 +25,7 @@ public fun generateKotlinAptAnnotation(outputDirectory: File): File {
|
||||
return outputFile
|
||||
}
|
||||
|
||||
public fun generateAnnotationProcessorWrapper(
|
||||
fun generateAnnotationProcessorWrapper(
|
||||
processorFqName: String,
|
||||
packageName: String,
|
||||
outputDirectory: File,
|
||||
|
||||
Reference in New Issue
Block a user