Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
a564724f
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a564724f
编写于
10月 06, 2015
作者:
A
Alexey Tsvetkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix issues with incremental cache version change
#KT-9360 fixed
上级
af3f7dfa
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
191 addition
and
39 deletion
+191
-39
jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt
...lugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt
+15
-34
jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt
.../jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt
+14
-5
jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalCacheVersionChangedTestGenerated.java
...ps/build/IncrementalCacheVersionChangedTestGenerated.java
+18
-0
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/build.log
.../incremental/cacheVersionChanged/exportedModule/build.log
+24
-0
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/dependencies.txt
...ental/cacheVersionChanged/exportedModule/dependencies.txt
+4
-0
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module1_A.kt
...cremental/cacheVersionChanged/exportedModule/module1_A.kt
+3
-0
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module1_A.kt.new
...ental/cacheVersionChanged/exportedModule/module1_A.kt.new
+3
-0
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module2_B.kt
...cremental/cacheVersionChanged/exportedModule/module2_B.kt
+7
-0
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module3_C.kt
...cremental/cacheVersionChanged/exportedModule/module3_C.kt
+7
-0
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module4_D.kt
...cremental/cacheVersionChanged/exportedModule/module4_D.kt
+7
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/build.log
.../cacheVersionChanged/moduleWithConstantModified/build.log
+18
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/dependencies.txt
...ersionChanged/moduleWithConstantModified/dependencies.txt
+2
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module1_A.kt
...cheVersionChanged/moduleWithConstantModified/module1_A.kt
+3
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module1_A.kt.new
...ersionChanged/moduleWithConstantModified/module1_A.kt.new
+3
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module2_B.kt
...cheVersionChanged/moduleWithConstantModified/module2_B.kt
+5
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module2_C.java
...eVersionChanged/moduleWithConstantModified/module2_C.java
+7
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/build.log
...al/cacheVersionChanged/moduleWithInlineModified/build.log
+21
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/dependencies.txt
...eVersionChanged/moduleWithInlineModified/dependencies.txt
+2
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module1_A.kt
...cacheVersionChanged/moduleWithInlineModified/module1_A.kt
+7
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module1_A.kt.new
...eVersionChanged/moduleWithInlineModified/module1_A.kt.new
+7
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module2_B.kt
...cacheVersionChanged/moduleWithInlineModified/module2_B.kt
+7
-0
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module2_C.java
...cheVersionChanged/moduleWithInlineModified/module2_C.java
+7
-0
未找到文件。
jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt
浏览文件 @
a564724f
...
...
@@ -30,15 +30,11 @@ import org.jetbrains.jps.builders.java.JavaBuilderUtil
import
org.jetbrains.jps.builders.java.JavaSourceRootDescriptor
import
org.jetbrains.jps.builders.java.dependencyView.Mappings
import
org.jetbrains.jps.incremental.*
import
org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.ABORT
import
org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.ADDITIONAL_PASS_REQUIRED
import
org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.NOTHING_DONE
import
org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.OK
import
org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.*
import
org.jetbrains.jps.incremental.fs.CompilationRound
import
org.jetbrains.jps.incremental.java.JavaBuilder
import
org.jetbrains.jps.incremental.messages.BuildMessage
import
org.jetbrains.jps.incremental.messages.CompilerMessage
import
org.jetbrains.jps.incremental.storage.StorageOwner
import
org.jetbrains.jps.model.JpsProject
import
org.jetbrains.jps.model.JpsSimpleElement
import
org.jetbrains.jps.model.ex.JpsElementChildRoleBase
...
...
@@ -141,10 +137,8 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
if
(
chunk
.
targets
.
any
{
dataManager
.
dataPaths
.
getKotlinCacheVersion
(
it
).
isIncompatible
()
})
{
LOG
.
info
(
"Clearing caches for "
+
chunk
.
targets
.
map
{
it
.
presentableName
}.
join
())
val
incrementalCaches
=
getIncrementalCaches
(
chunk
,
context
)
incrementalCaches
.
values
().
forEach
(
StorageOwner
::
clean
)
FSOperations
.
markDirtyRecursively
(
context
,
CompilationRound
.
NEXT
,
chunk
)
return
ADDITIONAL_PASS_REQUIRED
chunk
.
targets
.
forEach
{
dataManager
.
getKotlinCache
(
it
).
clean
()
}
return
CHUNK_REBUILD_REQUIRED
}
if
(!
dirtyFilesHolder
.
hasDirtyFiles
()
&&
!
dirtyFilesHolder
.
hasRemovedFiles
()
...
...
@@ -238,13 +232,22 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
}
private
fun
ChangesInfo
.
doProcessChanges
()
{
fun
isKotlin
(
file
:
File
)
=
KotlinSourceFileCollector
.
isKotlinSourceFile
(
file
)
fun
isNotCompiled
(
file
:
File
)
=
file
!
in
allCompiledFiles
when
{
inlineAdded
->
{
recompileEverything
()
allCompiledFiles
.
clear
()
FSOperations
.
markDirtyRecursively
(
context
,
CompilationRound
.
NEXT
,
chunk
,
::
isKotlin
)
return
}
constantsChanged
->
{
FSOperations
.
markDirtyRecursively
(
context
,
CompilationRound
.
NEXT
,
chunk
,
::
isNotCompiled
)
return
}
constantsChanged
->
recompileOtherAndDependents
()
protoChanged
->
recompileOtherKotlinInChunk
()
protoChanged
->
{
FSOperations
.
markDirty
(
context
,
CompilationRound
.
NEXT
,
chunk
,
{
isKotlin
(
it
)
&&
isNotCompiled
(
it
)
})
}
}
if
(
inlineChanged
)
{
...
...
@@ -261,28 +264,6 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
}
}
}
private
fun
recompileEverything
()
{
allCompiledFiles
.
clear
()
FSOperations
.
markDirtyRecursively
(
context
,
CompilationRound
.
NEXT
,
chunk
)
}
private
fun
recompileOtherAndDependents
()
{
// Workaround for IDEA 14.0-14.0.2: extended version of markDirtyRecursively is not available
try
{
Class
.
forName
(
"org.jetbrains.jps.incremental.fs.CompilationRound"
)
FSOperations
.
markDirtyRecursively
(
context
,
CompilationRound
.
NEXT
,
chunk
,
{
file
->
file
!
in
allCompiledFiles
})
}
catch
(
e
:
ClassNotFoundException
)
{
recompileEverything
()
}
}
private
fun
recompileOtherKotlinInChunk
()
{
FSOperations
.
markDirty
(
context
,
chunk
,
{
file
->
KotlinSourceFileCollector
.
isKotlinSourceFile
(
file
)
&&
file
!
in
allCompiledFiles
})
}
}
private
fun
doCompileModuleChunk
(
...
...
jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt
浏览文件 @
a564724f
...
...
@@ -40,6 +40,7 @@ import org.jetbrains.jps.incremental.ModuleBuildTarget
import
org.jetbrains.jps.incremental.messages.BuildMessage
import
org.jetbrains.jps.model.JpsElementFactory
import
org.jetbrains.jps.model.JpsModuleRootModificationUtil
import
org.jetbrains.jps.model.java.JpsJavaDependencyScope
import
org.jetbrains.jps.model.java.JpsJavaExtensionService
import
org.jetbrains.jps.util.JpsPathUtil
import
org.jetbrains.kotlin.incremental.components.LookupTracker
...
...
@@ -249,18 +250,17 @@ public abstract class AbstractIncrementalJpsTest(
rebuildAndCheckOutput
(
makeOverallResult
)
}
private
fun
readModuleDependencies
():
Map
<
String
,
List
<
String
>>?
{
private
fun
readModuleDependencies
():
Map
<
String
,
List
<
DependencyDescriptor
>>?
{
val
dependenciesTxt
=
File
(
testDataDir
,
"dependencies.txt"
)
if
(!
dependenciesTxt
.
exists
())
return
null
val
result
=
HashMap
<
String
,
List
<
String
>>()
val
result
=
HashMap
<
String
,
List
<
DependencyDescriptor
>>()
for
(
line
in
dependenciesTxt
.
readLines
())
{
val
split
=
line
.
split
(
"->"
)
val
module
=
split
[
0
]
val
dependencies
=
if
(
split
.
size
()
>
1
)
split
[
1
]
else
""
val
dependencyList
=
dependencies
.
split
(
","
).
filterNot
{
it
.
isEmpty
()
}
result
[
module
]
=
dependencyList
result
[
module
]
=
dependencyList
.
map
(
::
parseDependency
)
}
return
result
...
...
@@ -377,8 +377,10 @@ public abstract class AbstractIncrementalJpsTest(
for
((
moduleName
,
dependencies
)
in
moduleDependencies
)
{
val
module
=
nameToModule
[
moduleName
]
!!
for
(
dependency
in
dependencies
)
{
JpsModuleRootModificationUtil
.
addDependency
(
module
,
nameToModule
[
dependency
])
JpsModuleRootModificationUtil
.
addDependency
(
module
,
nameToModule
[
dependency
.
name
],
JpsJavaDependencyScope
.
COMPILE
,
dependency
.
exported
)
}
}
...
...
@@ -449,3 +451,10 @@ public abstract class AbstractIncrementalJpsTest(
internal
val
ProjectDescriptor
.
allModuleTargets
:
Collection
<
ModuleBuildTarget
>
get
()
=
buildTargetIndex
.
allTargets
.
filterIsInstance
<
ModuleBuildTarget
>()
private
class
DependencyDescriptor
(
val
name
:
String
,
val
exported
:
Boolean
)
private
fun
parseDependency
(
dependency
:
String
):
DependencyDescriptor
=
DependencyDescriptor
(
dependency
.
removeSuffix
(
EXPORTED_SUFFIX
),
dependency
.
endsWith
(
EXPORTED_SUFFIX
))
private
val
EXPORTED_SUFFIX
=
"[exported]"
jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalCacheVersionChangedTestGenerated.java
浏览文件 @
a564724f
...
...
@@ -35,6 +35,12 @@ public class IncrementalCacheVersionChangedTestGenerated extends AbstractIncreme
JetTestUtils
.
assertAllTestsPresentByMetadata
(
this
.
getClass
(),
new
File
(
"jps-plugin/testData/incremental/cacheVersionChanged"
),
Pattern
.
compile
(
"^([^\\.]+)$"
),
true
);
}
@TestMetadata
(
"exportedModule"
)
public
void
testExportedModule
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/"
);
doTest
(
fileName
);
}
@TestMetadata
(
"module1Modified"
)
public
void
testModule1Modified
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"jps-plugin/testData/incremental/cacheVersionChanged/module1Modified/"
);
...
...
@@ -47,6 +53,18 @@ public class IncrementalCacheVersionChangedTestGenerated extends AbstractIncreme
doTest
(
fileName
);
}
@TestMetadata
(
"moduleWithConstantModified"
)
public
void
testModuleWithConstantModified
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/"
);
doTest
(
fileName
);
}
@TestMetadata
(
"moduleWithInlineModified"
)
public
void
testModuleWithInlineModified
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/"
);
doTest
(
fileName
);
}
@TestMetadata
(
"touchedFile"
)
public
void
testTouchedFile
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"jps-plugin/testData/incremental/cacheVersionChanged/touchedFile/"
);
...
...
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/build.log
0 → 100644
浏览文件 @
a564724f
Cleaning output files:
out/production/module1/a/A.class
End of files
Compiling files:
module1/src/module1_A.kt
End of files
Cleaning output files:
out/production/module2/b/B.class
End of files
Compiling files:
module2/src/module2_B.kt
End of files
Cleaning output files:
out/production/module3/c/C.class
End of files
Compiling files:
module3/src/module3_C.kt
End of files
Cleaning output files:
out/production/module4/D/D.class
End of files
Compiling files:
module4/src/module4_D.kt
End of files
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/dependencies.txt
0 → 100644
浏览文件 @
a564724f
module1->
module2->module1[exported]
module3->module2
module4->module3
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module1_A.kt
0 → 100644
浏览文件 @
a564724f
package
a
open
class
A
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module1_A.kt.new
0 → 100644
浏览文件 @
a564724f
package
a
open
class
A
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module2_B.kt
0 → 100644
浏览文件 @
a564724f
package
b
import
a.A
open
class
B
{
val
a
=
A
()
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module3_C.kt
0 → 100644
浏览文件 @
a564724f
package
c
import
b.B
open
class
C
{
val
b
=
B
()
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/module4_D.kt
0 → 100644
浏览文件 @
a564724f
package
D
import
c.C
open
class
D
{
val
c
=
C
()
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/build.log
0 → 100644
浏览文件 @
a564724f
Cleaning output files:
out/production/module1/META-INF/module1.kotlin_module
out/production/module1/a/APackage.class
out/production/module1/a/Module1_AKt.class
End of files
Compiling files:
module1/src/module1_A.kt
End of files
Cleaning output files:
out/production/module2/b/B.class
out/production/module2/b/C.class
End of files
Compiling files:
module2/src/module2_B.kt
End of files
Compiling files:
module2/src/module2_C.java
End of files
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/dependencies.txt
0 → 100644
浏览文件 @
a564724f
module1->
module2->module1
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module1_A.kt
0 → 100644
浏览文件 @
a564724f
package
a
val
X
=
10
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module1_A.kt.new
0 → 100644
浏览文件 @
a564724f
package
a
val
X
=
11
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module2_B.kt
0 → 100644
浏览文件 @
a564724f
package
b
class
B
{
val
x
=
a
.
X
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithConstantModified/module2_C.java
0 → 100644
浏览文件 @
a564724f
package
b
;
class
C
{
C
()
{
new
B
();
}
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/build.log
0 → 100644
浏览文件 @
a564724f
Cleaning output files:
out/production/module1/META-INF/module1.kotlin_module
out/production/module1/a/A.class
out/production/module1/a/APackage.class
out/production/module1/a/Module1_AKt.class
End of files
Compiling files:
module1/src/module1_A.kt
End of files
Cleaning output files:
out/production/module2/b/B.class
End of files
Cleaning output files:
out/production/module2/b/C.class
End of files
Compiling files:
module2/src/module2_B.kt
End of files
Compiling files:
module2/src/module2_C.java
End of files
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/dependencies.txt
0 → 100644
浏览文件 @
a564724f
module1->
module2->module1
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module1_A.kt
0 → 100644
浏览文件 @
a564724f
package
a
open
class
A
inline
fun
f
():
A
{
return
A
()
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module1_A.kt.new
0 → 100644
浏览文件 @
a564724f
package
a
open
class
A
inline
fun
f
():
A
{
return
A
()
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module2_B.kt
0 → 100644
浏览文件 @
a564724f
package
b
import
a.*
open
class
B
{
val
a
=
f
()
}
\ No newline at end of file
jps-plugin/testData/incremental/cacheVersionChanged/moduleWithInlineModified/module2_C.java
0 → 100644
浏览文件 @
a564724f
package
b
;
class
C
{
C
()
{
new
B
();
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录