Browse Source

Build: Replace usage of deprecated JavaNativeInterfaceLibrary with JavaNativeInterfaceLibrary

m1
weisj 3 years ago
parent
commit
86345c849c
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 10
      buildSrc/src/main/kotlin/JniUtils.kt
  2. 6
      buildSrc/src/main/kotlin/UberJniJarPlugin.kt
  3. 4
      buildSrc/src/main/kotlin/UsePrebuiltBinariesWhenUnbuildablePlugin.kt

10
buildSrc/src/main/kotlin/JniUtils.kt

@ -1,5 +1,4 @@
import dev.nokee.platform.jni.JniLibraryDependencies
import org.gradle.nativeplatform.MachineArchitecture
import dev.nokee.platform.jni.JavaNativeInterfaceLibraryComponentDependencies
import dev.nokee.runtime.nativebase.OperatingSystemFamily
import dev.nokee.runtime.nativebase.TargetMachine
import dev.nokee.language.base.tasks.SourceCompile
@ -8,7 +7,6 @@ import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.ModuleDependencyCapabilitiesHandler
import org.gradle.api.provider.Provider
import org.gradle.nativeplatform.toolchain.Clang
import org.gradle.nativeplatform.toolchain.Gcc
@ -19,15 +17,15 @@ typealias OSFamily = org.gradle.nativeplatform.OperatingSystemFamily
fun MinimalExternalModuleDependency.dependencyNotation() =
"${module.group}:${module.name}:${versionConstraint.requiredVersion}"
fun JniLibraryDependencies.jvmLibImplementation(notation: Provider<MinimalExternalModuleDependency>) {
fun JavaNativeInterfaceLibraryComponentDependencies.jvmLibImplementation(notation: Provider<MinimalExternalModuleDependency>) {
jvmImplementation(notation.map { it.dependencyNotation() }.get())
}
fun JniLibraryDependencies.nativeLibImplementation(notation: Provider<MinimalExternalModuleDependency>) {
fun JavaNativeInterfaceLibraryComponentDependencies.nativeLibImplementation(notation: Provider<MinimalExternalModuleDependency>) {
nativeImplementation(notation.map { it.dependencyNotation() }.get())
}
fun JniLibraryDependencies.nativeLibImplementation(
fun JavaNativeInterfaceLibraryComponentDependencies.nativeLibImplementation(
notation: Provider<MinimalExternalModuleDependency>,
action: Action<in ModuleDependency>
) {

6
buildSrc/src/main/kotlin/UberJniJarPlugin.kt

@ -1,13 +1,11 @@
import dev.nokee.platform.jni.JarBinary
import dev.nokee.platform.jni.JniJarBinary
import dev.nokee.platform.jni.JniLibraryExtension
import dev.nokee.platform.jni.JavaNativeInterfaceLibrary
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.file.FileTree
import org.gradle.api.provider.Provider
import org.gradle.jvm.tasks.Jar
import org.gradle.nativeplatform.tasks.LinkSharedLibrary
class UberJniJarPlugin : Plugin<Project> {
@ -20,7 +18,7 @@ class UberJniJarPlugin : Plugin<Project> {
private fun configure(task: Jar) {
val project = task.project
val logger = task.logger
val library = project.extensions.getByType(JniLibraryExtension::class.java)
val library = project.extensions.getByType(JavaNativeInterfaceLibrary::class.java)
// Prevent variants from being published.
val targetMachines = library.targetMachines.forUseAtConfigurationTime().get()

4
buildSrc/src/main/kotlin/UsePrebuiltBinariesWhenUnbuildablePlugin.kt

@ -1,7 +1,7 @@
import dev.nokee.platform.jni.JavaNativeInterfaceLibrary
import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
import dev.nokee.platform.jni.JniLibraryExtension
import dev.nokee.platform.jni.JniLibrary
import java.io.File
@ -15,7 +15,7 @@ class UsePrebuiltBinariesWhenUnbuildablePlugin : Plugin<Project> {
override fun apply(target: Project) {
prebuiltExtension = target.extensions.create("prebuiltBinaries", PrebuiltBinariesExtension::class.java)
val library = target.extensions.getByType(JniLibraryExtension::class.java)
val library = target.extensions.getByType(JavaNativeInterfaceLibrary::class.java)
library.variants.configureEach {
if (prebuiltExtension.alwaysUsePrebuiltArtifact || !sharedLibrary.isBuildable) {
configure(target, this)

Loading…
Cancel
Save