diff --git a/build.gradle.kts b/build.gradle.kts index 8d054cb..843c1c3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.internal.os.OperatingSystem import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform +import org.jetbrains.kotlin.utils.addToStdlib.ifTrue /* the name of this project, default is the template version but you are free to change these */ group = "org.openrndr.template" @@ -71,155 +72,56 @@ val ormlFeatures = setOf( // "orml-u2net" ) - /* Which OPENRNDR libraries should be added to this project? */ val openrndrFeatures = setOf( "video" ) -/* Which version of OPENRNDR and ORX should be used? */ -val openrndrUseSnapshot = true -val openrndrVersion = if (openrndrUseSnapshot) "0.5.1-SNAPSHOT" else "0.4.0" - -val orxUseSnapshot = true -val orxVersion = if (orxUseSnapshot) "0.5.1-SNAPSHOT" else "0.4.0" - -val ormlUseSnapshot = true -val ormlVersion = if (ormlUseSnapshot) "0.5.1-SNAPSHOT" else "0.4.0" - -// choices are "orx-tensorflow-gpu", "orx-tensorflow-mkl", "orx-tensorflow" -val orxTensorflowBackend = "orx-tensorflow-mkl" - -// -val supportedPlatforms = setOf("windows", "macos", "linux-x64", "linux-arm64") - -val openrndrOs = if (project.hasProperty("targetPlatform")) { - val platform : String = project.property("targetPlatform") as String - if (platform !in supportedPlatforms) { - throw IllegalArgumentException("target platform not supported: $platform") - } else { - platform - } -} else when (OperatingSystem.current()) { - OperatingSystem.WINDOWS -> "windows" - OperatingSystem.MAC_OS -> "macos" - OperatingSystem.LINUX -> when(val h = DefaultNativePlatform("current").architecture.name) { - "x86-64" -> "linux-x64" - "aarch64" -> "linux-arm64" - else ->throw IllegalArgumentException("architecture not supported: $h") - } - else -> throw IllegalArgumentException("os not supported") -} -// - -enum class Logging { - NONE, - SIMPLE, - FULL -} - /* What type of logging should this project use? */ +enum class Logging { NONE, SIMPLE, FULL } + val applicationLogging = Logging.FULL -val kotlinVersion = "1.6.0" +// ------------------------------------------------------------------------------------------------------------------ // plugins { java - kotlin("jvm") version("1.6.0") - id("com.github.johnrengelman.shadow") version ("6.1.0") - id("org.beryx.runtime") version ("1.11.4") + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.shadow) + alias(libs.plugins.runtime) } repositories { mavenCentral() - if (openrndrUseSnapshot || orxUseSnapshot) { - mavenLocal() - } - maven(url = "https://maven.openrndr.org") -} - -fun DependencyHandler.orx(module: String): Any { - return "org.openrndr.extra:$module:$orxVersion" -} - -fun DependencyHandler.orml(module: String): Any { - return "org.openrndr.orml:$module:$ormlVersion" -} - -fun DependencyHandler.openrndr(module: String): Any { - return "org.openrndr:openrndr-$module:$openrndrVersion" -} - -fun DependencyHandler.openrndrNatives(module: String): Any { - return "org.openrndr:openrndr-$module-natives-$openrndrOs:$openrndrVersion" -} - -fun DependencyHandler.orxNatives(module: String): Any { - return "org.openrndr.extra:$module-natives-$openrndrOs:$orxVersion" } dependencies { - /* This is where you add additional (third-party) dependencies */ -// implementation("org.jsoup:jsoup:1.12.2") -// implementation("com.google.code.gson:gson:2.8.6") +// implementation(libs.jsoup) +// implementation(libs.gson) +// implementation(libs.csv) - runtimeOnly(openrndr("gl3")) - runtimeOnly(openrndrNatives("gl3")) - implementation(openrndr("openal")) - runtimeOnly(openrndrNatives("openal")) - implementation(openrndr("application")) - implementation(openrndr("svg")) - implementation(openrndr("animatable")) - implementation(openrndr("extensions")) - implementation(openrndr("filter")) - implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core","1.5.2") - implementation("io.github.microutils", "kotlin-logging-jvm","2.0.6") + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlin.logging) - when(applicationLogging) { + when (applicationLogging) { Logging.NONE -> { - runtimeOnly("org.slf4j","slf4j-nop","1.7.30") + runtimeOnly(libs.slf4j.nop) } Logging.SIMPLE -> { - runtimeOnly("org.slf4j","slf4j-simple","1.7.30") + runtimeOnly(libs.slf4j.simple) } Logging.FULL -> { - runtimeOnly("org.apache.logging.log4j", "log4j-slf4j-impl", "2.13.3") - runtimeOnly("com.fasterxml.jackson.core", "jackson-databind", "2.11.1") - runtimeOnly("com.fasterxml.jackson.dataformat", "jackson-dataformat-yaml", "2.11.1") + runtimeOnly(libs.log4j.slf4j) + runtimeOnly(libs.jackson.databind) + runtimeOnly(libs.jackson.json) } } - - if ("video" in openrndrFeatures) { - implementation(openrndr("ffmpeg")) - runtimeOnly(openrndrNatives("ffmpeg")) - } - - for (feature in orxFeatures) { - implementation(orx(feature)) - } - - for (feature in ormlFeatures) { - implementation(orml(feature)) - } - - if ("orx-tensorflow" in orxFeatures) { - runtimeOnly("org.openrndr.extra:$orxTensorflowBackend-natives-$openrndrOs:$orxVersion") - } - - if ("orx-kinect-v1" in orxFeatures) { - runtimeOnly(orxNatives("orx-kinect-v1")) - } - - if ("orx-olive" in orxFeatures) { - implementation("org.jetbrains.kotlin:kotlin-script-runtime:$kotlinVersion") - } - implementation(kotlin("stdlib-jdk8")) - testImplementation("junit", "junit", "4.12") + testImplementation(libs.junit) } -// -------------------------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------------------ // configure { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -228,6 +130,7 @@ tasks.withType { kotlinOptions.jvmTarget = "1.8" } +// ------------------------------------------------------------------------------------------------------------------ // project.setProperty("mainClassName", applicationMainClass) tasks { @@ -264,14 +167,18 @@ tasks { } } +// ------------------------------------------------------------------------------------------------------------------ // + tasks.register("jpackageZip") { - archiveFileName.set("openrndr-application-$openrndrOs.zip") + archiveFileName.set("openrndr-application.zip") from("$buildDir/jpackage") { include("**/*") } } tasks.findByName("jpackageZip")?.dependsOn("jpackage") +// ------------------------------------------------------------------------------------------------------------------ // + runtime { jpackage { imageName = "openrndr-application" @@ -290,3 +197,72 @@ runtime { modules.add("jdk.unsupported") modules.add("java.management") } + +// ------------------------------------------------------------------------------------------------------------------ // + +class Openrndr { + val openrndrVersion = libs.versions.openrndr.get() + val orxVersion = libs.versions.orx.get() + val ormlVersion = libs.versions.orml.get() + + // choices are "orx-tensorflow-gpu", "orx-tensorflow-mkl", "orx-tensorflow" + val orxTensorflowBackend = "orx-tensorflow-mkl" + + val os = if (project.hasProperty("targetPlatform")) { + val supportedPlatforms = setOf("windows", "macos", "linux-x64", "linux-arm64") + val platform: String = project.property("targetPlatform") as String + if (platform !in supportedPlatforms) { + throw IllegalArgumentException("target platform not supported: $platform") + } else { + platform + } + } else when (OperatingSystem.current()) { + OperatingSystem.WINDOWS -> "windows" + OperatingSystem.MAC_OS -> "macos" + OperatingSystem.LINUX -> when (val h = DefaultNativePlatform("current").architecture.name) { + "x86-64" -> "linux-x64" + "aarch64" -> "linux-arm64" + else -> throw IllegalArgumentException("architecture not supported: $h") + } + else -> throw IllegalArgumentException("os not supported") + } + + fun orx(module: String) = "org.openrndr.extra:$module:$orxVersion" + fun orml(module: String) = "org.openrndr.orml:$module:$ormlVersion" + fun openrndr(module: String) = "org.openrndr:openrndr-$module:$openrndrVersion" + fun openrndrNatives(module: String) = "org.openrndr:openrndr-$module-natives-$os:$openrndrVersion" + fun orxNatives(module: String) = "org.openrndr.extra:$module-natives-$os:$orxVersion" + + init { + repositories { + listOf(openrndrVersion, orxVersion, ormlVersion).any { it.contains("SNAPSHOT") }.ifTrue { mavenLocal() } + maven(url = "https://maven.openrndr.org") + } + dependencies { + runtimeOnly(openrndr("gl3")) + runtimeOnly(openrndrNatives("gl3")) + implementation(openrndr("openal")) + runtimeOnly(openrndrNatives("openal")) + implementation(openrndr("application")) + implementation(openrndr("svg")) + implementation(openrndr("animatable")) + implementation(openrndr("extensions")) + implementation(openrndr("filter")) + if ("video" in openrndrFeatures) { + implementation(openrndr("ffmpeg")) + runtimeOnly(openrndrNatives("ffmpeg")) + } + for (feature in orxFeatures) { + implementation(orx(feature)) + } + for (feature in ormlFeatures) { + implementation(orml(feature)) + } + if ("orx-tensorflow" in orxFeatures) runtimeOnly("org.openrndr.extra:$orxTensorflowBackend-natives-$os:$orxVersion") + if ("orx-kinect-v1" in orxFeatures) runtimeOnly(orxNatives("orx-kinect-v1")) + if ("orx-olive" in orxFeatures) implementation(libs.kotlin.script.runtime) + } + } +} + +val openrndr = Openrndr() diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 52bd101..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'openrndr-template' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..e9316a8 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,44 @@ +enableFeaturePreview("VERSION_CATALOGS") +rootProject.name = "openrndr-template" + +val openrndrUseSnapshot = true +val orxUseSnapshot = true +val ormlUseSnapshot = true + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + version("kotlin", "1.6.0") + version("openrndr", if (openrndrUseSnapshot) "0.5.1-SNAPSHOT" else "0.4.0") + version("orx", if (orxUseSnapshot) "0.5.1-SNAPSHOT" else "0.4.0") + version("orml", if (ormlUseSnapshot) "0.5.1-SNAPSHOT" else "0.4.0") + + alias("kotlin-jvm").toPluginId("org.jetbrains.kotlin.jvm").version("1.6.0") + alias("shadow").toPluginId("com.github.johnrengelman.shadow").version("7.1.0") + alias("runtime").toPluginId("org.beryx.runtime").version("1.12.7") + + alias("kotlin-script-runtime").to("org.jetbrains.kotlin", "kotlin-script-runtime").versionRef("kotlin") + + version("slf4j", "1.7.32") + alias("slf4j-nop").to("org.sl4j","slf4j-nop").versionRef("slf4j") + alias("slf4j-simple").to("org.sl4j","slf4j-simple").versionRef("slf4j") + + version("jackson", "2.11.1") + alias("jackson-databind").to("com.fasterxml.jackson.core", "jackson-databind").versionRef("jackson") + alias("jackson-json").to("com.fasterxml.jackson.dataformat", "jackson-dataformat-yaml").versionRef("jackson") + + version("log4j", "2.14.1") + alias("log4j-slf4j").to("org.apache.logging.log4j", "log4j-slf4j-impl").versionRef("log4j") + + version("kotlinx-coroutines", "1.5.2") + alias("kotlinx-coroutines-core").to("org.jetbrains.kotlinx", "kotlinx-coroutines-core").versionRef("kotlinx-coroutines") + + alias("kotlin-logging").to("io.github.microutils:kotlin-logging-jvm:2.0.10") + alias("junit").to("junit:junit:4.13.2") + + alias("jsoup").to("org.jsoup:jsoup:1.14.3") + alias("gson").to("com.google.code.gson:gson:2.8.7") + alias("csv").to("com.github.doyaaaaaken:kotlin-csv-jvm:1.2.0") + } + } +} \ No newline at end of file