IC should be enabled explicitly by build systems

The change only affects JPS on TeamCity (in Intellij IC system property
is always set explicitly; the same holds for Gradle, Maven).
Previous changes have effectively enabled the new IC (which is now default)
for TC JPS builds, which is undesirable as more RAM is used.
This commit is contained in:
Alexey Tsvetkov
2017-07-27 22:50:44 +03:00
parent 5ce3a436c7
commit 514635e965
4 changed files with 93 additions and 72 deletions
@@ -22,7 +22,7 @@ public class IncrementalCompilation {
private static final String INCREMENTAL_COMPILATION_PROPERTY = "kotlin.incremental.compilation"; private static final String INCREMENTAL_COMPILATION_PROPERTY = "kotlin.incremental.compilation";
public static boolean isEnabled() { public static boolean isEnabled() {
return !"false".equals(System.getProperty(INCREMENTAL_COMPILATION_PROPERTY)); return "true".equals(System.getProperty(INCREMENTAL_COMPILATION_PROPERTY));
} }
@TestOnly @TestOnly
+4 -1
View File
@@ -5,7 +5,10 @@
<sources path="s2"/> <sources path="s2"/>
<!-- Java source roots --> <!-- Java source roots -->
<!-- Classpath --> <!-- Classpath -->
<classpath path="cp1"/> <!-- Output directory, commented out -->
<!--
<classpath path="cp1"/>
-->
<classpath path="cp2"/> <classpath path="cp2"/>
</module> </module>
</modules> </modules>
+8 -2
View File
@@ -5,7 +5,10 @@
<sources path="s2"/> <sources path="s2"/>
<!-- Java source roots --> <!-- Java source roots -->
<!-- Classpath --> <!-- Classpath -->
<classpath path="cp1"/> <!-- Output directory, commented out -->
<!--
<classpath path="cp1"/>
-->
<classpath path="cp2"/> <classpath path="cp2"/>
</module> </module>
<!-- Module script for tests --> <!-- Module script for tests -->
@@ -14,7 +17,10 @@
<sources path="s22"/> <sources path="s22"/>
<!-- Java source roots --> <!-- Java source roots -->
<!-- Classpath --> <!-- Classpath -->
<classpath path="cp12"/> <!-- Output directory, commented out -->
<!--
<classpath path="cp12"/>
-->
<classpath path="cp22"/> <classpath path="cp22"/>
</module> </module>
</modules> </modules>
@@ -55,6 +55,7 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.JvmCodegenUtil import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY
import org.jetbrains.kotlin.incremental.CacheVersion import org.jetbrains.kotlin.incremental.CacheVersion
import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.incremental.components.LookupTracker
@@ -76,7 +77,68 @@ import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
import java.util.zip.ZipOutputStream import java.util.zip.ZipOutputStream
class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { class KotlinJpsBuildTestIncremental : KotlinJpsBuildTest() {
var isICEnabledBackup: Boolean = false
override fun setUp() {
super.setUp()
isICEnabledBackup = IncrementalCompilation.isEnabled()
IncrementalCompilation.setIsEnabled(true)
}
override fun tearDown() {
IncrementalCompilation.setIsEnabled(isICEnabledBackup)
super.tearDown()
}
fun testManyFiles() {
doTest()
val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"), arrayOf("src/Bar.kt"), arrayOf(klass("kotlinProject", "foo.Bar")))
checkWhen(del("src/main.kt"),
pathsToCompile = null,
pathsToDelete = packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
assertFilesExistInOutput(module, "boo/BooKt.class", "foo/Bar.class")
assertFilesNotExistInOutput(module, "foo/MainKt.class")
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"), null, arrayOf(klass("kotlinProject", "foo.Bar")))
}
fun testManyFilesForPackage() {
doTest()
val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"),
arrayOf("src/Bar.kt"),
arrayOf(klass("kotlinProject", "foo.Bar"),
packagePartClass("kotlinProject", "src/Bar.kt", "foo.MainKt"),
module("kotlinProject")))
checkWhen(del("src/main.kt"),
pathsToCompile = null,
pathsToDelete = packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
assertFilesExistInOutput(module, "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"), null,
arrayOf(klass("kotlinProject", "foo.Bar"),
packagePartClass("kotlinProject", "src/Bar.kt", "foo.MainKt"),
module("kotlinProject")))
}
}
open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
companion object { companion object {
private val PROJECT_NAME = "kotlinProject" private val PROJECT_NAME = "kotlinProject"
private val ADDITIONAL_MODULE_NAME = "module2" private val ADDITIONAL_MODULE_NAME = "module2"
@@ -156,7 +218,8 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
return result return result
} }
private fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) { @JvmStatic
protected fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) {
for (path in relativePaths) { for (path in relativePaths) {
val outputFile = findFileInOutputDir(module, path) val outputFile = findFileInOutputDir(module, path)
assertTrue("Output not written: " + outputFile.absolutePath + "\n Directory contents: \n" + dirContents(outputFile.parentFile), outputFile.exists()) assertTrue("Output not written: " + outputFile.absolutePath + "\n Directory contents: \n" + dirContents(outputFile.parentFile), outputFile.exists())
@@ -171,7 +234,8 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
} }
private fun assertFilesNotExistInOutput(module: JpsModule, vararg relativePaths: String) { @JvmStatic
protected fun assertFilesNotExistInOutput(module: JpsModule, vararg relativePaths: String) {
val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false)
assertNotNull(outputUrl) assertNotNull(outputUrl)
val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) val outputDir = File(JpsPathUtil.urlToPath(outputUrl))
@@ -190,22 +254,16 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
return builder.toString() return builder.toString()
} }
private fun klass(moduleName: String, classFqName: String): String { @JvmStatic
protected fun klass(moduleName: String, classFqName: String): String {
val outputDirPrefix = "out/production/$moduleName/" val outputDirPrefix = "out/production/$moduleName/"
return outputDirPrefix + classFqName.replace('.', '/') + ".class" return outputDirPrefix + classFqName.replace('.', '/') + ".class"
} }
private fun module(moduleName: String): String { @JvmStatic
protected fun module(moduleName: String): String {
return "out/production/$moduleName/${JvmCodegenUtil.getMappingFileName(moduleName)}" return "out/production/$moduleName/${JvmCodegenUtil.getMappingFileName(moduleName)}"
} }
fun mergeArrays(vararg stringArrays: Array<String>): Array<String> {
val result = HashSet<String>()
for (array in stringArrays) {
result.addAll(Arrays.asList(*array))
}
return ArrayUtil.toStringArray(result)
}
} }
annotation class WorkingDir(val name: String) annotation class WorkingDir(val name: String)
@@ -486,52 +544,6 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING) checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING)
} }
fun testManyFiles() {
doTest()
val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"), arrayOf("src/Bar.kt"), arrayOf(klass("kotlinProject", "foo.Bar")))
checkWhen(del("src/main.kt"),
pathsToCompile = null,
pathsToDelete = packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
assertFilesExistInOutput(module, "boo/BooKt.class", "foo/Bar.class")
assertFilesNotExistInOutput(module, "foo/MainKt.class")
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"), null, arrayOf(klass("kotlinProject", "foo.Bar")))
}
fun testManyFilesForPackage() {
doTest()
val module = myProject.modules.get(0)
assertFilesExistInOutput(module, "foo/MainKt.class", "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"),
arrayOf("src/Bar.kt"),
arrayOf(klass("kotlinProject", "foo.Bar"),
packagePartClass("kotlinProject", "src/Bar.kt", "foo.MainKt"),
module("kotlinProject")))
checkWhen(del("src/main.kt"),
pathsToCompile = null,
pathsToDelete = packageClasses("kotlinProject", "src/main.kt", "foo.MainKt"))
assertFilesExistInOutput(module, "boo/BooKt.class", "foo/Bar.class")
checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooKt"))
checkWhen(touch("src/Bar.kt"), null,
arrayOf(klass("kotlinProject", "foo.Bar"),
packagePartClass("kotlinProject", "src/Bar.kt", "foo.MainKt"),
module("kotlinProject")))
}
fun testKotlinProjectTwoFilesInOnePackage() { fun testKotlinProjectTwoFilesInOnePackage() {
doTest() doTest()
@@ -1025,11 +1037,11 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
throw IllegalStateException("Couldn't find module $name") throw IllegalStateException("Couldn't find module $name")
} }
private fun checkWhen(action: Action, pathsToCompile: Array<String>?, pathsToDelete: Array<String>?) { protected fun checkWhen(action: Action, pathsToCompile: Array<String>?, pathsToDelete: Array<String>?) {
checkWhen(arrayOf(action), pathsToCompile, pathsToDelete) checkWhen(arrayOf(action), pathsToCompile, pathsToDelete)
} }
private fun checkWhen(actions: Array<Action>, pathsToCompile: Array<String>?, pathsToDelete: Array<String>?) { protected fun checkWhen(actions: Array<Action>, pathsToCompile: Array<String>?, pathsToDelete: Array<String>?) {
for (action in actions) { for (action in actions) {
action.apply() action.apply()
} }
@@ -1045,11 +1057,11 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
} }
} }
private fun packageClasses(moduleName: String, fileName: String, packageClassFqName: String): Array<String> { protected fun packageClasses(moduleName: String, fileName: String, packageClassFqName: String): Array<String> {
return arrayOf(module(moduleName), packagePartClass(moduleName, fileName, packageClassFqName)) return arrayOf(module(moduleName), packagePartClass(moduleName, fileName, packageClassFqName))
} }
private fun packagePartClass(moduleName: String, fileName: String, packageClassFqName: String): String { protected fun packagePartClass(moduleName: String, fileName: String, packageClassFqName: String): String {
val path = FileUtilRt.toSystemIndependentName(File(workDir, fileName).absolutePath) val path = FileUtilRt.toSystemIndependentName(File(workDir, fileName).absolutePath)
val fakeVirtualFile = object : LightVirtualFile(path.substringAfterLast('/')) { val fakeVirtualFile = object : LightVirtualFile(path.substringAfterLast('/')) {
override fun getPath(): String { override fun getPath(): String {
@@ -1062,19 +1074,19 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
return klass(moduleName, AsmUtil.internalNameByFqNameWithoutInnerClasses(packagePartFqName)) return klass(moduleName, AsmUtil.internalNameByFqNameWithoutInnerClasses(packagePartFqName))
} }
private enum class Operation { protected enum class Operation {
CHANGE, CHANGE,
DELETE DELETE
} }
private fun touch(path: String): Action = Action(Operation.CHANGE, path) protected fun touch(path: String): Action = Action(Operation.CHANGE, path)
private fun del(path: String): Action = Action(Operation.DELETE, path) protected fun del(path: String): Action = Action(Operation.DELETE, path)
// TODO inline after KT-3974 will be fixed // TODO inline after KT-3974 will be fixed
private fun touch(file: File): Unit = JpsBuildTestCase.change(file.absolutePath) protected fun touch(file: File): Unit = JpsBuildTestCase.change(file.absolutePath)
private inner class Action constructor(private val operation: Operation, private val path: String) { protected inner class Action constructor(private val operation: Operation, private val path: String) {
fun apply() { fun apply() {
val file = File(workDir, path) val file = File(workDir, path)
when (operation) { when (operation) {