Browse Source

Fix issue where not all binaries are included in jar.

pull/198/head
weisj 4 years ago
parent
commit
7ba3347b7b
  1. 5
      buildSrc/build.gradle.kts
  2. 0
      buildSrc/settings.gradle.kts
  3. 8
      buildSrc/src/main/groovy/JniUtils.groovy
  4. 12
      buildSrc/src/main/groovy/UberJniJarPlugin.groovy

5
buildSrc/build.gradle.kts

@ -2,7 +2,6 @@ apply(from= "../gradle/loadProps.gradle.kts")
plugins { plugins {
`java-gradle-plugin` `java-gradle-plugin`
`kotlin-dsl`
groovy groovy
} }
@ -31,7 +30,3 @@ gradlePlugin {
} }
} }
} }
configure<KotlinDslPluginOptions> {
experimentalWarning.set(false)
}

0
buildSrc/settings.gradle.kts

8
buildSrc/src/main/groovy/JniUtils.groovy

@ -1,5 +1,5 @@
import dev.nokee.platform.nativebase.OperatingSystemFamily import dev.nokee.runtime.nativebase.OperatingSystemFamily
import dev.nokee.platform.nativebase.TargetMachine import dev.nokee.runtime.nativebase.TargetMachine
import org.gradle.api.GradleException import org.gradle.api.GradleException
import org.gradle.api.Project import org.gradle.api.Project
@ -8,10 +8,12 @@ class JniUtils {
String operatingSystemFamily = 'macos' String operatingSystemFamily = 'macos'
if (targetMachine.operatingSystemFamily.windows) { if (targetMachine.operatingSystemFamily.windows) {
operatingSystemFamily = 'windows' operatingSystemFamily = 'windows'
} else if (targetMachine.operatingSystemFamily.linux) {
operatingSystemFamily = 'linux'
} }
String architecture = 'x86-64' String architecture = 'x86-64'
if (targetMachine.architecture.'32Bit') { if (targetMachine.architecture.is32Bit()) {
architecture = 'x86' architecture = 'x86'
} }

12
buildSrc/src/main/groovy/UberJniJarPlugin.groovy

@ -1,7 +1,7 @@
import dev.nokee.platform.jni.JniJarBinary import dev.nokee.platform.jni.JniJarBinary
import dev.nokee.platform.jni.JniLibrary import dev.nokee.platform.jni.JniLibrary
import dev.nokee.platform.jni.JniLibraryExtension import dev.nokee.platform.jni.JniLibraryExtension
import dev.nokee.platform.nativebase.TargetMachine import dev.nokee.runtime.nativebase.TargetMachine
import groovy.transform.CompileStatic import groovy.transform.CompileStatic
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
@ -27,8 +27,8 @@ class UberJniJarPlugin implements Plugin<Project> {
library.binaries.withType(JniJarBinary).configureEach { library.binaries.withType(JniJarBinary).configureEach {
if (it.jarTask.isPresent()) it.jarTask.get()?.enabled = false if (it.jarTask.isPresent()) it.jarTask.get()?.enabled = false
} }
if (library.targetMachines.get().size() >= 1) { logger.info("${project.name}: Merging binaries into the JVM Jar.")
logger.info("${project.name}: Merging binaries into the JVM Jar.") if (library.targetMachines.get().size() > 1) {
for (TargetMachine targetMachine : library.targetMachines.get()) { for (TargetMachine targetMachine : library.targetMachines.get()) {
Provider<JniLibrary> variant = library.variants Provider<JniLibrary> variant = library.variants
.flatMap(targetMachineOf(targetMachine)) .flatMap(targetMachineOf(targetMachine))
@ -37,6 +37,12 @@ class UberJniJarPlugin implements Plugin<Project> {
spec.from(variant.map { it.nativeRuntimeFiles }) spec.from(variant.map { it.nativeRuntimeFiles })
} }
} }
} else {
library.variants.configureEach {
task.into(it.resourcePath) { CopySpec spec ->
spec.from(it.nativeRuntimeFiles)
}
}
} }
} }

Loading…
Cancel
Save