Do not try to remove source annotations from not .class file
This commit is contained in:
+1
@@ -8,6 +8,7 @@ class AnnotationsRemover(annotations: Iterable<String>) {
|
||||
private val annotations = annotations.mapTo(HashSet()) { "L$it;" }
|
||||
|
||||
fun transformClassFile(inputFile: File, outputFile: File) {
|
||||
assert(inputFile.extension.toLowerCase() == "class") { "Expected class file: $inputFile" }
|
||||
val bytes = inputFile.readBytes()
|
||||
val reader = ClassReader(bytes)
|
||||
val classWriter = ClassWriter(0)
|
||||
|
||||
+4
-3
@@ -144,11 +144,12 @@ open class SyncOutputTask : DefaultTask() {
|
||||
if (!fileInKotlinDir.isFile) return
|
||||
|
||||
fileInJavaDir.parentFile.mkdirs()
|
||||
if (sourceAnnotations.isEmpty()) {
|
||||
fileInKotlinDir.copyTo(fileInJavaDir, overwrite = true)
|
||||
if (sourceAnnotations.isNotEmpty() && fileInKotlinDir.extension.toLowerCase() == "class") {
|
||||
logger.kotlinDebug { "Removing source annotations from class: $fileInKotlinDir" }
|
||||
annotationsRemover.transformClassFile(fileInKotlinDir, fileInJavaDir)
|
||||
}
|
||||
else {
|
||||
annotationsRemover.transformClassFile(fileInKotlinDir, fileInJavaDir)
|
||||
fileInKotlinDir.copyTo(fileInJavaDir, overwrite = true)
|
||||
}
|
||||
|
||||
timestamps[fileInJavaDir] = fileInJavaDir.lastModified()
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
fun topLevelDummyFun() {}
|
||||
Reference in New Issue
Block a user