@@ -187,28 +187,37 @@ kotlin {
187
187
}
188
188
}
189
189
}
190
-
191
- jvm {
192
- withJava()
193
- }
194
190
}
195
191
196
192
tasks {
197
- named<JavaCompile >(" compileJava" ) {
193
+ val compileModuleInfo by registering(JavaCompile ::class ) {
194
+ classpath = objects.fileCollection()
195
+ .from(configurations.named(" jvmCompileClasspath" ))
198
196
val compileKotlinJvm = named<KotlinCompile >(" compileKotlinJvm" )
199
197
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" ))
204
206
}
205
207
206
208
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
+ }
207
214
val bndConvention = BundleTaskConvention (this )
208
215
bndConvention.setBnd(
209
216
"""
210
217
Export-Package: okio
218
+ Multi-Release: true
211
219
Bundle-SymbolicName: com.squareup.okio
220
+ -fixupmessages: ^Classes found in the wrong directory: \\{META-INF/versions/9/module-info.class=module-info}${' $' }
212
221
""" ,
213
222
)
214
223
// Call the convention when the task has finished to modify the jar to contain OSGi metadata.
0 commit comments