Print file paths relative to project root in gradle incremental compilation logs
KT-8487
This commit is contained in:
@@ -220,13 +220,14 @@ fun mapLookupSymbolsToFiles(
|
|||||||
lookupStorage: LookupStorage,
|
lookupStorage: LookupStorage,
|
||||||
lookupSymbols: Iterable<LookupSymbol>,
|
lookupSymbols: Iterable<LookupSymbol>,
|
||||||
log: (String)->Unit,
|
log: (String)->Unit,
|
||||||
|
getLogFilePath: (File)->String = { it.canonicalPath },
|
||||||
excludes: Set<File> = emptySet()
|
excludes: Set<File> = emptySet()
|
||||||
): Set<File> {
|
): Set<File> {
|
||||||
val dirtyFiles = HashSet<File>()
|
val dirtyFiles = HashSet<File>()
|
||||||
|
|
||||||
for (lookup in lookupSymbols) {
|
for (lookup in lookupSymbols) {
|
||||||
val affectedFiles = lookupStorage.get(lookup).map(::File).filter { it !in excludes }
|
val affectedFiles = lookupStorage.get(lookup).map(::File).filter { it !in excludes }
|
||||||
log("${lookup.scope}#${lookup.name} caused recompilation of: $affectedFiles")
|
log("${lookup.scope}#${lookup.name} caused recompilation of: ${affectedFiles.map(getLogFilePath)}")
|
||||||
dirtyFiles.addAll(affectedFiles)
|
dirtyFiles.addAll(affectedFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +238,7 @@ fun <Target> mapClassesFqNamesToFiles(
|
|||||||
caches: Iterable<IncrementalCacheImpl<Target>>,
|
caches: Iterable<IncrementalCacheImpl<Target>>,
|
||||||
classesFqNames: Iterable<FqName>,
|
classesFqNames: Iterable<FqName>,
|
||||||
log: (String)->Unit,
|
log: (String)->Unit,
|
||||||
|
getLogFilePath: (File)->String = { it.canonicalPath },
|
||||||
excludes: Set<File> = emptySet()
|
excludes: Set<File> = emptySet()
|
||||||
): Set<File> {
|
): Set<File> {
|
||||||
val dirtyFiles = HashSet<File>()
|
val dirtyFiles = HashSet<File>()
|
||||||
@@ -246,7 +248,7 @@ fun <Target> mapClassesFqNamesToFiles(
|
|||||||
val srcFile = cache.getSourceFileIfClass(dirtyClassFqName)
|
val srcFile = cache.getSourceFileIfClass(dirtyClassFqName)
|
||||||
if (srcFile == null || srcFile in excludes) continue
|
if (srcFile == null || srcFile in excludes) continue
|
||||||
|
|
||||||
log("Class $dirtyClassFqName caused recompilation of: $srcFile")
|
log("Class $dirtyClassFqName caused recompilation of: ${getLogFilePath(srcFile)}")
|
||||||
dirtyFiles.add(srcFile)
|
dirtyFiles.add(srcFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -161,8 +161,6 @@ open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments>() {
|
|||||||
"compileReleaseUnitTestKotlin" to "compileReleaseKotlin"
|
"compileReleaseUnitTestKotlin" to "compileReleaseKotlin"
|
||||||
)
|
)
|
||||||
|
|
||||||
fun projectRelativePath(f: File) = f.toRelativeString(project.projectDir)
|
|
||||||
|
|
||||||
// TODO: find out whether we really need to be able to override destination dir here, and how it should work with destinationDir property
|
// TODO: find out whether we really need to be able to override destination dir here, and how it should work with destinationDir property
|
||||||
private val compilerDestinationDir: String get() = if (StringUtils.isEmpty(kotlinOptions.destination)) { kotlinDestinationDir?.path.orEmpty() } else { kotlinOptions.destination }
|
private val compilerDestinationDir: String get() = if (StringUtils.isEmpty(kotlinOptions.destination)) { kotlinDestinationDir?.path.orEmpty() } else { kotlinOptions.destination }
|
||||||
|
|
||||||
@@ -220,6 +218,8 @@ open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments>() {
|
|||||||
|
|
||||||
override fun callCompiler(args: K2JVMCompilerArguments, sources: List<File>, isIncrementalRequested: Boolean, modified: List<File>, removed: List<File>, cachesBaseDir: File) {
|
override fun callCompiler(args: K2JVMCompilerArguments, sources: List<File>, isIncrementalRequested: Boolean, modified: List<File>, removed: List<File>, cachesBaseDir: File) {
|
||||||
|
|
||||||
|
fun projectRelativePath(f: File) = f.toRelativeString(project.projectDir)
|
||||||
|
|
||||||
if (experimentalIncremental) {
|
if (experimentalIncremental) {
|
||||||
// TODO: consider other ways to pass incremental flag to compiler/builder
|
// TODO: consider other ways to pass incremental flag to compiler/builder
|
||||||
System.setProperty("kotlin.incremental.compilation", "true")
|
System.setProperty("kotlin.incremental.compilation", "true")
|
||||||
@@ -280,7 +280,7 @@ open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments>() {
|
|||||||
|
|
||||||
if (lookupSymbols.any()) {
|
if (lookupSymbols.any()) {
|
||||||
val kotlinModifiedFilesSet = modifiedKotlinFiles.toHashSet()
|
val kotlinModifiedFilesSet = modifiedKotlinFiles.toHashSet()
|
||||||
val dirtyFilesFromLookups = mapLookupSymbolsToFiles(lookupStorage, lookupSymbols, logAction, excludes = kotlinModifiedFilesSet)
|
val dirtyFilesFromLookups = mapLookupSymbolsToFiles(lookupStorage, lookupSymbols, logAction, ::projectRelativePath, excludes = kotlinModifiedFilesSet)
|
||||||
modifiedKotlinFiles.addAll(dirtyFilesFromLookups)
|
modifiedKotlinFiles.addAll(dirtyFilesFromLookups)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,8 +434,8 @@ open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments>() {
|
|||||||
if (!isIncrementalDecided) break;
|
if (!isIncrementalDecided) break;
|
||||||
|
|
||||||
val (dirtyLookupSymbols, dirtyClassFqNames) = compilationResult.getDirtyData(caches.values, logAction)
|
val (dirtyLookupSymbols, dirtyClassFqNames) = compilationResult.getDirtyData(caches.values, logAction)
|
||||||
sourcesToCompile = mapLookupSymbolsToFiles(lookupStorage, dirtyLookupSymbols, logAction, excludes = sourcesToCompile) +
|
sourcesToCompile = mapLookupSymbolsToFiles(lookupStorage, dirtyLookupSymbols, logAction, ::projectRelativePath, excludes = sourcesToCompile) +
|
||||||
mapClassesFqNamesToFiles(caches.values, dirtyClassFqNames, logAction)
|
mapClassesFqNamesToFiles(caches.values, dirtyClassFqNames, logAction, ::projectRelativePath)
|
||||||
|
|
||||||
if (currentRemoved.any()) {
|
if (currentRemoved.any()) {
|
||||||
currentRemoved = listOf()
|
currentRemoved = listOf()
|
||||||
|
|||||||
Reference in New Issue
Block a user