Skip to content

Commit 8924329

Browse files
committed
Move module-info.class file to versions directory
1 parent bffc4da commit 8924329

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

okio/build.gradle.kts

+18-9
Original file line numberDiff line numberDiff line change
@@ -187,28 +187,37 @@ kotlin {
187187
}
188188
}
189189
}
190-
191-
jvm {
192-
withJava()
193-
}
194190
}
195191

196192
tasks {
197-
named<JavaCompile>("compileJava") {
193+
val compileModuleInfo by registering(JavaCompile::class) {
194+
classpath = objects.fileCollection()
195+
.from(configurations.named("jvmCompileClasspath"))
198196
val compileKotlinJvm = named<KotlinCompile>("compileKotlinJvm")
199197
dependsOn(compileKotlinJvm)
200-
options.compilerArgumentProviders.plusAssign(CommandLineArgumentProvider {
201-
listOf("--patch-module", "okio=${compileKotlinJvm.get().destinationDirectory.get().asFile.absolutePath}")
202-
})
203-
options.release.set(11)
198+
options.compilerArgumentProviders.plusAssign(
199+
CommandLineArgumentProvider {
200+
listOf("--patch-module", "okio=${compileKotlinJvm.get().destinationDirectory.get().asFile.absolutePath}")
201+
},
202+
)
203+
destinationDirectory = layout.buildDirectory.dir("classes/java/moduleInfo")
204+
options.release = 9
205+
source(layout.projectDirectory.dir("src/jvmMain/java"))
204206
}
205207

206208
val jvmJar by getting(Jar::class) {
209+
// BundleTaskConvention() crashes unless there's a 'main' source set.
210+
sourceSets.create(SourceSet.MAIN_SOURCE_SET_NAME)
211+
from(compileModuleInfo) {
212+
into("META-INF/versions/9")
213+
}
207214
val bndConvention = BundleTaskConvention(this)
208215
bndConvention.setBnd(
209216
"""
210217
Export-Package: okio
218+
Multi-Release: true
211219
Bundle-SymbolicName: com.squareup.okio
220+
-fixupmessages: ^Classes found in the wrong directory: \\{META-INF/versions/9/module-info.class=module-info}${'$'}
212221
""",
213222
)
214223
// Call the convention when the task has finished to modify the jar to contain OSGi metadata.

0 commit comments

Comments
 (0)