From 3f55afa9a8b90d8d094e32d9c99b32eba6e3476a Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Thu, 11 Jul 2019 21:08:10 +0200 Subject: [PATCH] Migrate to Gradle Kotlin DSL, fix fat JAR --- extras/EsotericSoftwareSpine/CMakeLists.txt | 2 +- extras/EsotericSoftwareSpine/build.gradle | 47 ------------------ extras/EsotericSoftwareSpine/build.gradle.kts | 48 +++++++++++++++++++ extras/EsotericSoftwareSpine/settings.gradle | 2 - .../EsotericSoftwareSpine/settings.gradle.kts | 1 + 5 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 extras/EsotericSoftwareSpine/build.gradle create mode 100644 extras/EsotericSoftwareSpine/build.gradle.kts delete mode 100644 extras/EsotericSoftwareSpine/settings.gradle create mode 100644 extras/EsotericSoftwareSpine/settings.gradle.kts diff --git a/extras/EsotericSoftwareSpine/CMakeLists.txt b/extras/EsotericSoftwareSpine/CMakeLists.txt index 28786d2..c341cdd 100644 --- a/extras/EsotericSoftwareSpine/CMakeLists.txt +++ b/extras/EsotericSoftwareSpine/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.2) add_custom_target( rhubarbForSpine ALL - "./gradlew" "jar" + "./gradlew" "shadowJar" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Building Rhubarb for Spine through Gradle." ) diff --git a/extras/EsotericSoftwareSpine/build.gradle b/extras/EsotericSoftwareSpine/build.gradle deleted file mode 100644 index c459cbb..0000000 --- a/extras/EsotericSoftwareSpine/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -plugins { - id 'org.jetbrains.kotlin.jvm' version '1.3.41' -} - -def getVersion() { - // Dynamically read version from CMake file - String text = new File('../../appInfo.cmake').getText('UTF-8') - String major = (text =~ /appVersionMajor\s+(\d+)/)[0][1] - String minor = (text =~ /appVersionMinor\s+(\d+)/)[0][1] - String patch = (text =~ /appVersionPatch\s+(\d+)/)[0][1] - String suffix = (text =~ /appVersionSuffix\s+"(.*?)"/)[0][1] - String result = "${major}.${minor}.${patch}${suffix}" - return result -} - -group 'com.rhubarb_lip_sync' -version = getVersion() - -repositories { - mavenCentral() - jcenter() -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" - implementation 'com.beust:klaxon:5.0.1' - implementation 'org.apache.commons:commons-lang3:3.9' - implementation 'no.tornado:tornadofx:1.7.19' -} - -compileKotlin { - kotlinOptions.jvmTarget = '1.8' -} -compileTestKotlin { - kotlinOptions.jvmTarget = '1.8' -} - -jar { - manifest { - attributes 'Main-Class': 'com.rhubarb_lip_sync.rhubarb_for_spine.MainKt' - } - - // This line of code recursively collects and copies all of a project's files - // and adds them to the JAR itself. One can extend this task, to skip certain - // files or particular types at will - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } -} \ No newline at end of file diff --git a/extras/EsotericSoftwareSpine/build.gradle.kts b/extras/EsotericSoftwareSpine/build.gradle.kts new file mode 100644 index 0000000..6eae674 --- /dev/null +++ b/extras/EsotericSoftwareSpine/build.gradle.kts @@ -0,0 +1,48 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.io.File +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + kotlin("jvm") version "1.3.41" + id("com.github.johnrengelman.shadow") version "5.1.0" +} + +fun getVersion(): String { + // Dynamically read version from CMake file + val file = File(rootDir.parentFile.parentFile, "appInfo.cmake") + val text = file.readText() + val major = Regex("""appVersionMajor\s+(\d+)""").find(text)!!.groupValues[1] + val minor = Regex("""appVersionMinor\s+(\d+)""").find(text)!!.groupValues[1] + val patch = Regex("""appVersionPatch\s+(\d+)""").find(text)!!.groupValues[1] + val suffix = Regex("""appVersionSuffix\s+"(.*?)"""").find(text)!!.groupValues[1] + return "$major.$minor.$patch$suffix" +} + +group = "com.rhubarb_lip_sync" +version = getVersion() + +repositories { + mavenCentral() + jcenter() +} + +dependencies { + implementation(kotlin("stdlib-jdk8")) + implementation("com.beust:klaxon:5.0.1") + implementation("org.apache.commons:commons-lang3:3.9") + implementation("no.tornado:tornadofx:1.7.19") +} + +tasks.withType { + kotlinOptions.jvmTarget = "1.8" +} + +tasks.jar { + manifest { + attributes("Main-Class" to "com.rhubarb_lip_sync.rhubarb_for_spine.MainKt") + } +} + +tasks.shadowJar { + archiveClassifier.set(null as String?) +} diff --git a/extras/EsotericSoftwareSpine/settings.gradle b/extras/EsotericSoftwareSpine/settings.gradle deleted file mode 100644 index dc991a3..0000000 --- a/extras/EsotericSoftwareSpine/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'rhubarb-for-spine' - diff --git a/extras/EsotericSoftwareSpine/settings.gradle.kts b/extras/EsotericSoftwareSpine/settings.gradle.kts new file mode 100644 index 0000000..6e921c8 --- /dev/null +++ b/extras/EsotericSoftwareSpine/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "rhubarb-for-spine"