-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of 'previous-compilation-data.bin' in META-INF (#3675)
* Include only module-info.class from the corresponding JavaCompile task Fixes #3668
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
integration-testing/src/mavenTest/kotlin/MavenPublicationMetaInfValidator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.coroutines.validator | ||
|
||
import org.junit.Test | ||
import org.objectweb.asm.* | ||
import org.objectweb.asm.ClassReader.* | ||
import org.objectweb.asm.ClassWriter.* | ||
import org.objectweb.asm.Opcodes.* | ||
import java.util.jar.* | ||
import kotlin.test.* | ||
|
||
class MavenPublicationMetaInfValidator { | ||
|
||
@Test | ||
fun testMetaInfCoreStructure() { | ||
val clazz = Class.forName("kotlinx.coroutines.Job") | ||
JarFile(clazz.protectionDomain.codeSource.location.file).checkMetaInfStructure( | ||
setOf( | ||
"MANIFEST.MF", | ||
"kotlinx-coroutines-core.kotlin_module", | ||
"com.android.tools/proguard/coroutines.pro", | ||
"com.android.tools/r8/coroutines.pro", | ||
"proguard/coroutines.pro", | ||
"versions/9/module-info.class", | ||
"kotlinx_coroutines_core.version" | ||
) | ||
) | ||
} | ||
|
||
@Test | ||
fun testMetaInfAndroidStructure() { | ||
val clazz = Class.forName("kotlinx.coroutines.android.HandlerDispatcher") | ||
JarFile(clazz.protectionDomain.codeSource.location.file).checkMetaInfStructure( | ||
setOf( | ||
"MANIFEST.MF", | ||
"kotlinx-coroutines-android.kotlin_module", | ||
"services/kotlinx.coroutines.CoroutineExceptionHandler", | ||
"services/kotlinx.coroutines.internal.MainDispatcherFactory", | ||
"com.android.tools/r8-from-1.6.0/coroutines.pro", | ||
"com.android.tools/r8-upto-3.0.0/coroutines.pro", | ||
"com.android.tools/proguard/coroutines.pro", | ||
"proguard/coroutines.pro", | ||
"versions/9/module-info.class", | ||
"kotlinx_coroutines_android.version" | ||
) | ||
) | ||
} | ||
|
||
private fun JarFile.checkMetaInfStructure(expected: Set<String>) { | ||
val actual = HashSet<String>() | ||
for (e in entries()) { | ||
if (e.isDirectory() || !e.realName.contains("META-INF")) { | ||
continue | ||
} | ||
val partialName = e.realName.substringAfter("META-INF/") | ||
actual.add(partialName) | ||
} | ||
|
||
if (actual != expected) { | ||
val intersection = actual.intersect(expected) | ||
val mismatch = actual.subtract(intersection) + expected.subtract(intersection) | ||
fail("Mismatched files: " + mismatch) | ||
} | ||
|
||
close() | ||
} | ||
} |