From afc63de01e54fb70062a99440c92edc9d4354bdd Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Tue, 26 Jul 2022 03:19:47 +0300 Subject: [PATCH] gradle: check operating system --- README.MD | 4 +-- client/build.gradle | 35 ++++++++++++++----- .../text2speech-1.10.3-natives-linux.jar | 3 ++ ...m-2.9.4-nightly-20150209-natives-linux.jar | 3 ++ 4 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 libs/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux.jar create mode 100644 libs/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar diff --git a/README.MD b/README.MD index 7450e2e..a87d43b 100644 --- a/README.MD +++ b/README.MD @@ -7,11 +7,11 @@ ## Run Client ```shell -gradle client:run +gradle :client:copyNatives :client:run ``` ## Run Server ```shell -gradle client:run +gradle :server:run ``` \ No newline at end of file diff --git a/client/build.gradle b/client/build.gradle index 9ab80f5..ce76d39 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -1,3 +1,5 @@ +import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform + plugins { id 'java' id 'application' @@ -5,6 +7,7 @@ plugins { group = 'minecraft' version = '1.12.2' +OperatingSystem os = DefaultNativePlatform.currentOperatingSystem compileJava { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 @@ -21,7 +24,7 @@ run { workingDir.mkdir() } - systemProperty 'java.library.path', file("$buildDir/natives/windows") + systemProperty 'java.library.path', file("$buildDir/natives") args '--version', '1.12.2', '--accessToken', '0', '--assetsDir', 'assets', '--assetIndex', "1.12.2", '--userProperties', '{}' } @@ -35,7 +38,6 @@ dependencies { implementation name: 'com/mojang/authlib/1.5.25/authlib-1.5.25' implementation name: 'com/mojang/text2speech/1.10.3/text2speech-1.10.3' implementation name: 'com/mojang/realms/1.10.21/realms-1.10.21' - implementation name: 'com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-windows' implementation name: 'com/paulscode/codecjorbis/20101023/codecjorbis-20101023' implementation name: 'com/paulscode/codecwav/20101023/codecwav-20101023' implementation name: 'com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123' @@ -44,9 +46,16 @@ dependencies { implementation name: 'oshi-project/oshi-core/1.1/oshi-core-1.1' implementation name: 'org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209' implementation name: 'org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209' - implementation name: 'org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-windows' implementation name: 'com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2' + if (os.isWindows()) { + implementation name: 'com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-windows' + implementation name: 'org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-windows' + } else { + implementation name: 'com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux' + implementation name: 'org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux' + } + implementation 'net.java.dev.jna:jna:4.4.0' implementation 'net.java.jinput:jinput:2.0.5' implementation 'net.java.jinput:jinput-platform:2.0.5' @@ -63,13 +72,23 @@ dependencies { implementation 'commons-codec:commons-codec:1.10' } -task copyNativesWindows { +tasks.register('copyNatives').configure { doLast { + def classifier + def suffix + if (os.isWindows()) { + classifier = 'natives-windows' + suffix = '-natives-windows' + } else { + classifier = 'natives-linux' + suffix = '-natives-linux' + } + copy { - def resolvedArtifacts = configurations.compile.resolvedConfiguration.resolvedArtifacts - def matches = resolvedArtifacts.findAll {it.classifier == 'natives-windows' || it.name.endsWith('-natives-windows')} - from matches.collect { it.file }.collect { zipTree(it) } - into "$buildDir/natives/windows" + def resolvedArtifacts = configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts + def matches = resolvedArtifacts.findAll {it.classifier == classifier || it.name.endsWith(suffix)} + from matches.collect { it.file }.collect { zipTree(it).matching { exclude 'META-INF/**' } } + into "$buildDir/natives" } } } diff --git a/libs/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux.jar b/libs/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux.jar new file mode 100644 index 0000000..3aafc6c --- /dev/null +++ b/libs/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30f85b0ff695941095f73ede14cc55c0ca1f0fdc34f15c4906c95d5e1d545209 +size 7833 diff --git a/libs/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar b/libs/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar new file mode 100644 index 0000000..0855525 --- /dev/null +++ b/libs/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d312147c3999b868fd649887f45203a4195bc10fc563cee4c4f8d22761421f94 +size 578680