Skip to content

Commit

Permalink
Replace Gradle Natives plugin with a manual approach
Browse files Browse the repository at this point in the history
In an effort to get the jinput native binaries extracted, I decided to get rid of the external Gradle Natives plugin which has been abandoned in the meantime.
Unfortunately the custom "natives-all" classifier doesn't seem to work in correlation with settings.gradle.kts and the VersionCatalogBuilder.
Seems like classifiers are unsupported - at least I didn't find any way to achieve it which is why had to manually add it to the build.gradle.kts file.
  • Loading branch information
steffen-wilke committed Dec 4, 2021
1 parent dcb6c6c commit df8cf8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 13 additions & 5 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
jacoco
signing
`maven-publish`
id("com.stehno.natives")
id("org.sonarqube")
}

Expand All @@ -15,8 +14,11 @@ description = """
It provides a comprehensive Java library and a dedicated map editor to create tile-based 2D games.
""".trimIndent()

val native: Configuration by configurations.creating

dependencies {
implementation(libs.bundles.jinput)
implementation(libs.jinput.core)
native(group=libs.jinput.core.get().module.group, name = libs.jinput.core.get().module.name, version = libs.jinput.core.get().versionConstraint.requiredVersion, classifier = "natives-all")

This comment has been minimized.

Copy link
@weisJ

weisJ Dec 5, 2021

Contributor

This should work:

native(libs.jinput.core) {
  artifact {
    classifier = "natives-all"
  }
}

This comment has been minimized.

Copy link
@steffen-wilke

steffen-wilke Dec 5, 2021

Author Contributor

That's a bit nicer, thanks :)

implementation(libs.bundles.soundlibs)
implementation(libs.steamworks)
implementation(libs.javax.activation)
Expand All @@ -26,11 +28,17 @@ dependencies {
testImplementation(projects.litiengineShared)
}

natives {
configurations = listOf("runtimeClasspath")
outputDir = "libs"
tasks.register<Copy>("natives") {
for(dep in configurations.runtimeClasspath.get().files + native.files) {
from(zipTree(dep).files)
include("**/*.dll", "**/*.so", "**/*.jnilib", "**/*.dylib")
into(File(buildDir, "libs"))
}
}

tasks.named("jar") {
dependsOn("natives")
}
tasks {
test {
workingDir = buildDir.resolve("test")
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ litiengine.version = 0.5.1-beta

# Plugins
org.sonarqube.version = 3.2.0
com.stehno.natives.version = 0.3.1
com.github.vlsi.vlsi-release-plugins.version = 1.74
org.beryx.runtime.version = 1.12.6
ktlint.version = 0.42.0
Expand Down
7 changes: 0 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ rootProject.name = "litiengine"
pluginManagement {
plugins {
fun idv(id: String, key: String = id) = id(id) version extra["$key.version"].toString()
idv("com.stehno.natives")
idv("org.sonarqube")
idv("org.beryx.runtime")
idv("com.github.vlsi.crlf", "com.github.vlsi.vlsi-release-plugins")
Expand Down Expand Up @@ -34,12 +33,6 @@ dependencyResolutionManagement {

alias("jinput-core").to("net.java.jinput", "jinput")
.versionRef("jinput")
alias("jinput-natives").to("net.java.jinput", "jinput")
.version("${extra["jinput.version"]}:natives-all")
bundle(
"jinput",
listOf("jinput-core", "jinput-natives")
)

alias("soundlibs-jorbis").to("com.googlecode.soundlibs", "jorbis")
.versionRef("soundlibs.jorbis")
Expand Down

0 comments on commit df8cf8b

Please sign in to comment.