Kapt: Remove kapt1 support from Gradle and incremental compilation
This commit is contained in:
+1
-13
@@ -16,16 +16,4 @@
|
||||
|
||||
package org.jetbrains.kotlin.daemon.common
|
||||
|
||||
import java.rmi.RemoteException
|
||||
|
||||
interface IncrementalCompilerServicesFacade : CompilerServicesFacadeBase {
|
||||
// AnnotationFileUpdater
|
||||
@Throws(RemoteException::class)
|
||||
fun hasAnnotationsFileUpdater(): Boolean
|
||||
|
||||
@Throws(RemoteException::class)
|
||||
fun updateAnnotations(outdatedClassesJvmNames: Iterable<String>)
|
||||
|
||||
@Throws(RemoteException::class)
|
||||
fun revert()
|
||||
}
|
||||
interface IncrementalCompilerServicesFacade : CompilerServicesFacadeBase
|
||||
@@ -40,7 +40,6 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.daemon.common.*
|
||||
import org.jetbrains.kotlin.daemon.incremental.RemoteAnnotationsFileUpdater
|
||||
import org.jetbrains.kotlin.daemon.report.CompileServicesFacadeMessageCollector
|
||||
import org.jetbrains.kotlin.daemon.report.DaemonMessageReporter
|
||||
import org.jetbrains.kotlin.daemon.report.DaemonMessageReporterPrintStreamAdapter
|
||||
@@ -486,7 +485,6 @@ class CompileServiceImpl(
|
||||
daemonMessageReporter: DaemonMessageReporter
|
||||
): ExitCode {
|
||||
val reporter = RemoteICReporter(servicesFacade, compilationResults, incrementalCompilationOptions)
|
||||
val annotationFileUpdater = if (servicesFacade.hasAnnotationsFileUpdater()) RemoteAnnotationsFileUpdater(servicesFacade) else null
|
||||
|
||||
val moduleFile = k2jvmArgs.buildFile?.let(::File)
|
||||
assert(moduleFile?.exists() ?: false) { "Module does not exist ${k2jvmArgs.buildFile}" }
|
||||
@@ -536,7 +534,7 @@ class CompileServiceImpl(
|
||||
workingDir,
|
||||
javaSourceRoots,
|
||||
versions,
|
||||
reporter, annotationFileUpdater,
|
||||
reporter,
|
||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
||||
localStateDirs = incrementalCompilationOptions.localStateDirs,
|
||||
usePreciseJavaTracking = incrementalCompilationOptions.usePreciseJavaTracking,
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.daemon.incremental
|
||||
|
||||
import org.jetbrains.kotlin.annotation.AnnotationFileUpdater
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.daemon.common.IncrementalCompilerServicesFacade
|
||||
import org.jetbrains.kotlin.daemon.common.IncrementalCompilationServicesFacade
|
||||
import org.jetbrains.kotlin.incremental.ICReporter
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import java.io.File
|
||||
|
||||
internal class RemoteAnnotationsFileUpdater(private val servicesFacade: IncrementalCompilerServicesFacade) : AnnotationFileUpdater {
|
||||
override fun updateAnnotations(outdatedClasses: Iterable<JvmClassName>) {
|
||||
servicesFacade.updateAnnotations(outdatedClasses.map { it.internalName })
|
||||
}
|
||||
|
||||
override fun revert() {
|
||||
servicesFacade.revert()
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.annotation
|
||||
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
|
||||
/**
|
||||
* Annotation file is generated by collecting annotated elements of generated files.
|
||||
* When compiling incrementally, the compiler generates only subset of all classes,
|
||||
* so after compilation annotation file contains only a subset of annotated elements,
|
||||
* which breaks the build.
|
||||
*
|
||||
* The workaround is to:
|
||||
* 1. backup old file before incremental compilation;
|
||||
* 2. after each iteration of IC:
|
||||
* 2.1 remove classes corresponding to dirty source files
|
||||
* 2.2 add annotations from newly generated annotations file
|
||||
*/
|
||||
interface AnnotationFileUpdater {
|
||||
fun updateAnnotations(outdatedClasses: Iterable<JvmClassName>)
|
||||
fun revert()
|
||||
}
|
||||
|
||||
+5
-21
@@ -22,7 +22,6 @@ import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiFileFactory
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
import org.jetbrains.kotlin.annotation.AnnotationFileUpdater
|
||||
import org.jetbrains.kotlin.build.GeneratedFile
|
||||
import org.jetbrains.kotlin.build.GeneratedJvmClass
|
||||
import org.jetbrains.kotlin.build.JvmSourceRoot
|
||||
@@ -103,7 +102,6 @@ class IncrementalJvmCompilerRunner(
|
||||
private val javaSourceRoots: Set<JvmSourceRoot>,
|
||||
cacheVersions: List<CacheVersion>,
|
||||
reporter: ICReporter,
|
||||
private var kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null,
|
||||
private val usePreciseJavaTracking: Boolean,
|
||||
private val buildHistoryFile: File,
|
||||
localStateDirs: Collection<File>,
|
||||
@@ -311,28 +309,14 @@ class IncrementalJvmCompilerRunner(
|
||||
}
|
||||
|
||||
override fun preBuildHook(args: K2JVMCompilerArguments, compilationMode: CompilationMode) {
|
||||
when (compilationMode) {
|
||||
is CompilationMode.Incremental -> {
|
||||
val destinationDir = args.destinationAsFile
|
||||
destinationDir.mkdirs()
|
||||
args.classpathAsList = listOf(destinationDir) + args.classpathAsList
|
||||
}
|
||||
is CompilationMode.Rebuild -> {
|
||||
// there is no point in updating annotation file since all files will be compiled anyway
|
||||
kaptAnnotationsFileUpdater = null
|
||||
}
|
||||
if (compilationMode is CompilationMode.Incremental) {
|
||||
val destinationDir = args.destinationAsFile
|
||||
destinationDir.mkdirs()
|
||||
args.classpathAsList = listOf(destinationDir) + args.classpathAsList
|
||||
}
|
||||
}
|
||||
|
||||
override fun postCompilationHook(exitCode: ExitCode) {
|
||||
if (exitCode == ExitCode.OK) {
|
||||
// TODO: Is it ok that argument always was an empty list?
|
||||
kaptAnnotationsFileUpdater?.updateAnnotations(emptyList())
|
||||
}
|
||||
else {
|
||||
kaptAnnotationsFileUpdater?.revert()
|
||||
}
|
||||
}
|
||||
override fun postCompilationHook(exitCode: ExitCode) {}
|
||||
|
||||
override fun updateCaches(
|
||||
services: Services,
|
||||
|
||||
Reference in New Issue
Block a user