Skip to content

Commit 88adead

Browse files
committed
Migrate to kotlin-multiplatform plugin
1 parent 2a1197f commit 88adead

File tree

194 files changed

+558
-724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+558
-724
lines changed

LICENSE

100644100755
File mode changed.

ReadMe.md

100644100755
File mode changed.

benchmarks/build.gradle

100644100755
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1+
2+
13
plugins {
24
id 'me.champeau.gradle.jmh' version '0.4.5'
35
}
46

57
apply plugin: 'kotlin-allopen'
68

9+
kotlin {
10+
targets {
11+
fromPreset(presets.jvmWithJava, 'jvmWithJava')
12+
}
13+
}
714

815
dependencies {
9-
jmh project(':kotlinx-io-jvm')
10-
jmh project(':kotlinx-io-jvm').sourceSets.test.output
11-
}
16+
jmh rootProject
17+
jmh rootProject.kotlin.targets.jvm.compilations.main.output.allOutputs
18+
jmh rootProject.kotlin.targets.jvm.compilations.test.output.allOutputs
19+
jmhCompile rootProject
20+
jmhCompile rootProject.kotlin.targets.jvm.compilations.test.output.allOutputs
21+
22+
compile group: 'org.openjdk.jmh', name: 'jmh-core', version: '1.21'
1223

24+
jmhCompileClasspath rootProject
25+
jmhCompileClasspath rootProject.kotlin.targets.jvm.compilations.main.output.allOutputs
26+
jmhCompileClasspath rootProject.kotlin.targets.jvm.compilations.test.output.allOutputs
27+
jmhRuntimeClasspath rootProject
28+
jmhRuntimeClasspath rootProject.kotlin.targets.jvm.compilations.main.output.allOutputs
29+
jmhRuntimeClasspath rootProject.kotlin.targets.jvm.compilations.test.output.allOutputs
30+
}
1331
allOpen {
1432
annotation('org.openjdk.jmh.annotations.State')
1533
}
@@ -19,7 +37,6 @@ jmh {
1937
jmhJar {
2038
archiveName = 'benchmarks.jar'
2139
}
22-
2340
// include = ['.*.myInput2?$', '.*.bufferInputStream']
2441
// exclude = ['.*Guice.*', '.*PingPong.*']
2542
}

benchmarks/src/jmh/kotlin/kotlinx/io/tests/benchmarks/PacketReadBenchmark.kt

100644100755
File mode changed.

benchmarks/src/jmh/kotlin/kotlinx/io/tests/benchmarks/TextDecodeBenchmark.kt

100644100755
File mode changed.

binary-compatibility-validator/build.gradle

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,47 @@
55
configurations {
66
testArtifacts
77
}
8+
kotlin {
9+
sourceSets {
10+
jvmMain {
11+
dependencies {
12+
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
13+
14+
api rootProject
15+
api project(':kotlinx-coroutines-io')
16+
17+
api 'org.ow2.asm:asm-debug-all:5.2'
18+
api 'com.google.code.gson:gson:2.6.2'
19+
}
20+
}
21+
jvmTest {
22+
dependencies {
23+
api "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
24+
api "junit:junit:4.12"
25+
}
26+
}
27+
}
28+
}
829

930
dependencies {
10-
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
11-
12-
compile project(":kotlinx-io-jvm")
13-
compile 'org.ow2.asm:asm-debug-all:5.0.4'
14-
compile 'com.google.code.gson:gson:2.6.2'
15-
16-
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
17-
testCompile "junit:junit:4.12"
18-
19-
testArtifacts project(':kotlinx-io-jvm')
20-
testArtifacts project(':kotlinx-coroutines-io:kotlinx-coroutines-io-jvm')
31+
testArtifacts rootProject
32+
testArtifacts project(':kotlinx-coroutines-io')
2133
}
2234

23-
sourceSets {
24-
main {
25-
kotlin {
26-
srcDir 'src'
27-
}
28-
}
29-
test {
30-
kotlin {
31-
srcDir 'test'
32-
}
35+
jvmTest {
36+
dependencies {
3337
}
34-
}
3538

36-
test {
37-
dependsOn cleanCompileTestKotlin
38-
dependsOn configurations.testArtifacts
39+
def modules = configurations.testArtifacts.dependencies.findAll { it instanceof ProjectDependency }.collect {
40+
it.dependencyProject.projectDir
41+
}
3942

40-
def modules = configurations.testArtifacts.dependencies.findAll { it instanceof ProjectDependency }.collect { it.dependencyProject.projectDir }
43+
def artifactNames = configurations.testArtifacts.dependencies.findAll { it instanceof ProjectDependency }.collect {
44+
it.dependencyProject.name
45+
}
4146

4247
systemProperty 'validator.input.modules', modules.join(File.pathSeparator)
48+
systemProperty 'validator.input.artifactNames', artifactNames.join(File.pathSeparator)
4349
systemProperty 'overwrite.output', project.properties['overwrite.output']
4450
jvmArgs '-ea'
4551
}

binary-compatibility-validator/src/PublicApiDump.kt renamed to binary-compatibility-validator/jvm/src/PublicApiDump.kt

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,29 @@ fun getBinaryAPI(
3232
val classAccess = AccessFlags(effectiveAccess and Opcodes.ACC_STATIC.inv())
3333
val supertypes = listOf(superName) - "java/lang/Object" + interfaces.sorted()
3434

35-
val memberSignatures = (
36-
fields.map {
37-
with(it) {
38-
FieldBinarySignature(
39-
name,
40-
desc,
41-
isPublishedApi(),
42-
AccessFlags(access)
43-
)
44-
}
45-
} +
46-
methods.map {
47-
with(it) {
48-
MethodBinarySignature(
49-
name,
50-
desc,
51-
isPublishedApi(),
52-
AccessFlags(access)
53-
)
54-
}
55-
}
56-
).filter {
35+
val fieldSignatures = fields.map {
36+
with(it) {
37+
FieldBinarySignature(
38+
name,
39+
desc,
40+
isPublishedApi(),
41+
AccessFlags(access)
42+
)
43+
}
44+
}
45+
46+
val methodSignatures = methods.map {
47+
with(it) {
48+
MethodBinarySignature(
49+
name,
50+
desc,
51+
isPublishedApi(),
52+
AccessFlags(access)
53+
)
54+
}
55+
}
56+
57+
val memberSignatures = (fieldSignatures + methodSignatures).filter {
5758
it.isEffectivelyPublic(classAccess, classVisibility)
5859
}
5960

binary-compatibility-validator/src/asmUtils.kt renamed to binary-compatibility-validator/jvm/src/asmUtils.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ data class AccessFlags(val access: Int) {
111111
val isSynthetic: Boolean get() = isSynthetic(access)
112112

113113
fun getModifiers(): List<String> =
114-
ACCESS_NAMES.entries.mapNotNull { if (access and it.key != 0) it.value else null }
114+
ACCESS_NAMES.entries.filter { access and it.key != 0 }.map { it.value }
115115

116116
fun getModifierString(): String = getModifiers().joinToString(" ")
117117
}
@@ -123,8 +123,7 @@ fun isFinal(access: Int) = access and Opcodes.ACC_FINAL != 0
123123
fun isSynthetic(access: Int) = access and Opcodes.ACC_SYNTHETIC != 0
124124

125125

126-
fun ClassNode.isEffectivelyPublic(classVisibility: ClassVisibility?) =
127-
isPublic(access)
126+
fun ClassNode.isEffectivelyPublic(classVisibility: ClassVisibility?) = isPublic(access)
128127
&& !isLocal()
129128
&& !isWhenMappings()
130129
&& (classVisibility?.isPublic(isPublishedApi()) ?: true)

binary-compatibility-validator/src/kotlinVisibilities.kt renamed to binary-compatibility-validator/jvm/src/kotlinVisibilities.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ fun ClassVisibility.findSetterForProperty(property: MemberVisibility): MemberVis
3636
}
3737

3838
fun readKotlinVisibilities(declarationFile: File): Map<String, ClassVisibility> {
39+
check(declarationFile.exists())
40+
3941
val result = mutableListOf<ClassVisibility>()
4042
declarationFile.bufferedReader().use { reader ->
4143
val jsonReader = JsonReader(reader)

binary-compatibility-validator/test/PublicApiTest.kt renamed to binary-compatibility-validator/jvm/test/PublicApiTest.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ class PublicApiTest(
1717
) {
1818
companion object {
1919
private val modulesList = System.getProperty("validator.input.modules")
20+
private val artifactNamesList = System.getProperty("validator.input.artifactNames")
2021
private val nonPublicPackages: List<String> = emptyList()
2122

2223
@Parameterized.Parameters(name = "{1}")
2324
@JvmStatic
2425
fun modules(): List<Array<Any>> {
25-
return modulesList.split(File.pathSeparator).map { path ->
26-
val dir = File(path)
27-
arrayOf<Any>(dir, dir.name)
28-
}
26+
val names = artifactNamesList.split(File.pathSeparator)
27+
return modulesList
28+
.split(File.pathSeparator)
29+
.map { path -> File(path) }
30+
.zip(names)
31+
.map { it.toList().toTypedArray() }
2932
}
3033
}
3134

@@ -39,11 +42,11 @@ class PublicApiTest(
3942
.map { readKotlinVisibilities(it) }
4043
.reduce { m1, m2 -> m1 + m2 }
4144
val api = getBinaryAPI(JarFile(jarFile), visibilities).filterOutNonPublic(nonPublicPackages)
42-
api.dumpAndCompareWith(File("reference-public-api").resolve("$moduleName.txt"))
45+
api.dumpAndCompareWith(File("reference-public-api").resolve("$moduleName-jvm.txt"))
4346
}
4447

4548
private fun getJarPath(libsDir: File): File {
46-
val regex = Regex("$moduleName-.+\\.jar")
49+
val regex = Regex("$moduleName-jvm.+\\.jar")
4750
val files = (libsDir.listFiles() ?: throw Exception("Cannot list files in $libsDir"))
4851
.filter {
4952
it.name.let {

binary-compatibility-validator/test/utils.kt renamed to binary-compatibility-validator/jvm/test/utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private fun assertEqualsToFile(to: File, actual: CharSequence) {
3535
assertEquals(
3636
expectedText,
3737
actualText,
38-
"Actual data differs from file content: ${to.name}\nTo overwrite the expected API rerun with -Doverwrite.output=true parameter\n"
38+
"Actual data differs from file content: ${to.name}\nTo overwrite the expected API rerun with -Poverwrite.output=true parameter\n"
3939
)
4040
}
4141

0 commit comments

Comments
 (0)