Browse Source

Add version catalog

master
Edwin Jakobs 3 years ago
parent
commit
e988a14f03
  1. 214
      build.gradle.kts
  2. 2
      settings.gradle
  3. 44
      settings.gradle.kts

214
build.gradle.kts

@ -2,6 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.os.OperatingSystem import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform 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 */ /* the name of this project, default is the template version but you are free to change these */
group = "org.openrndr.template" group = "org.openrndr.template"
@ -71,155 +72,56 @@ val ormlFeatures = setOf<String>(
// "orml-u2net" // "orml-u2net"
) )
/* Which OPENRNDR libraries should be added to this project? */ /* Which OPENRNDR libraries should be added to this project? */
val openrndrFeatures = setOf( val openrndrFeatures = setOf(
"video" "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"
//<editor-fold desc="This is code for OPENRNDR, no need to edit this .. most of the times">
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")
}
//</editor-fold>
enum class Logging {
NONE,
SIMPLE,
FULL
}
/* What type of logging should this project use? */ /* What type of logging should this project use? */
enum class Logging { NONE, SIMPLE, FULL }
val applicationLogging = Logging.FULL val applicationLogging = Logging.FULL
val kotlinVersion = "1.6.0" // ------------------------------------------------------------------------------------------------------------------ //
plugins { plugins {
java java
kotlin("jvm") version("1.6.0") alias(libs.plugins.kotlin.jvm)
id("com.github.johnrengelman.shadow") version ("6.1.0") alias(libs.plugins.shadow)
id("org.beryx.runtime") version ("1.11.4") alias(libs.plugins.runtime)
} }
repositories { repositories {
mavenCentral() 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 { dependencies {
/* This is where you add additional (third-party) dependencies */
// implementation("org.jsoup:jsoup:1.12.2") // implementation(libs.jsoup)
// implementation("com.google.code.gson:gson:2.8.6") // implementation(libs.gson)
// implementation(libs.csv)
runtimeOnly(openrndr("gl3")) implementation(libs.kotlinx.coroutines.core)
runtimeOnly(openrndrNatives("gl3")) implementation(libs.kotlin.logging)
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")
when(applicationLogging) { when (applicationLogging) {
Logging.NONE -> { Logging.NONE -> {
runtimeOnly("org.slf4j","slf4j-nop","1.7.30") runtimeOnly(libs.slf4j.nop)
} }
Logging.SIMPLE -> { Logging.SIMPLE -> {
runtimeOnly("org.slf4j","slf4j-simple","1.7.30") runtimeOnly(libs.slf4j.simple)
} }
Logging.FULL -> { Logging.FULL -> {
runtimeOnly("org.apache.logging.log4j", "log4j-slf4j-impl", "2.13.3") runtimeOnly(libs.log4j.slf4j)
runtimeOnly("com.fasterxml.jackson.core", "jackson-databind", "2.11.1") runtimeOnly(libs.jackson.databind)
runtimeOnly("com.fasterxml.jackson.dataformat", "jackson-dataformat-yaml", "2.11.1") 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")) implementation(kotlin("stdlib-jdk8"))
testImplementation("junit", "junit", "4.12") testImplementation(libs.junit)
} }
// -------------------------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------------------------------ //
configure<JavaPluginConvention> { configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
@ -228,6 +130,7 @@ tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8" kotlinOptions.jvmTarget = "1.8"
} }
// ------------------------------------------------------------------------------------------------------------------ //
project.setProperty("mainClassName", applicationMainClass) project.setProperty("mainClassName", applicationMainClass)
tasks { tasks {
@ -264,14 +167,18 @@ tasks {
} }
} }
// ------------------------------------------------------------------------------------------------------------------ //
tasks.register<Zip>("jpackageZip") { tasks.register<Zip>("jpackageZip") {
archiveFileName.set("openrndr-application-$openrndrOs.zip") archiveFileName.set("openrndr-application.zip")
from("$buildDir/jpackage") { from("$buildDir/jpackage") {
include("**/*") include("**/*")
} }
} }
tasks.findByName("jpackageZip")?.dependsOn("jpackage") tasks.findByName("jpackageZip")?.dependsOn("jpackage")
// ------------------------------------------------------------------------------------------------------------------ //
runtime { runtime {
jpackage { jpackage {
imageName = "openrndr-application" imageName = "openrndr-application"
@ -290,3 +197,72 @@ runtime {
modules.add("jdk.unsupported") modules.add("jdk.unsupported")
modules.add("java.management") 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()

2
settings.gradle

@ -1,2 +0,0 @@
rootProject.name = 'openrndr-template'

44
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")
}
}
}
Loading…
Cancel
Save