Browse Source

Merge pull request #131 from vlsi/run_demo

Add gradlew runDemo task to lauch demos from the command line
pull/139/head
Jannis Weis 5 years ago committed by GitHub
parent
commit
42f54075f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      core/build.gradle.kts

32
core/build.gradle.kts

@ -63,3 +63,35 @@ tasks.shadowJar {
exclude("com/sun/jna/sunos-x86/") exclude("com/sun/jna/sunos-x86/")
exclude("com/sun/jna/sunos-x86-64/") exclude("com/sun/jna/sunos-x86-64/")
} }
abstract class DemoTask : JavaExec() {
init {
setMain("UIDemo")
}
@Option(option = "class", description = "Specifies the main class to run (e.g. UIDemo, ui.table.TableDemo, ui.button.ButtonDemo, ...)")
override fun setMain(mainClassName: String?) = super.setMain(mainClassName)
}
val runDemo by tasks.registering(DemoTask::class) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Launches demo (e.g. UIDemo, ui.table.TableDemo, ui.button.ButtonDemo, ...)"
classpath(sourceSets.test.map { it.runtimeClasspath })
// Pass the property to the demo
// By default JavaExec is executed in its own JVM with its own properties
// It allows to pass system properties via gradlew -Ddarklaf.prop=value
fun passProperty(name: String, default: String? = null) {
val value = System.getProperty(name) ?: default
value?.let { systemProperty(name, it) }
}
val props = System.getProperties()
@Suppress("UNCHECKED_CAST")
for (e in props.propertyNames() as `java.util`.Enumeration<String>) {
if (e.startsWith("darklaf.")) {
passProperty(e)
}
}
passProperty("java.awt.headless")
}

Loading…
Cancel
Save