Add screenshot generation

This commit is contained in:
Edwin Jakobs
2020-04-22 21:56:08 +02:00
parent 6a29853c71
commit 60a64806fc
66 changed files with 1316 additions and 84 deletions

View File

@@ -16,7 +16,7 @@ buildscript {
apply plugin: 'org.jetbrains.dokka'
project.ext {
openrndrVersion = "0.3.41"
openrndrVersion = "0.4.0-SNAPSHOT"
kotlinVersion = "1.3.72"
spekVersion = "2.0.10"
libfreenectVersion = "0.5.7-1.5.3"
@@ -62,6 +62,7 @@ allprojects {
group 'org.openrndr.extra'
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
@@ -124,4 +125,39 @@ allprojects {
includeEngines 'spek2'
}
}
}
task collectScreenshots(dependsOn: 'classes') {
doFirst {
for (sub in project.subprojects) {
if (sub.sourceSets.hasProperty("demo")) {
def set = sub.sourceSets.demo
def ucl = new URLClassLoader(set.runtimeClasspath.collect { it.toURI().toURL() } as URL[])
for (x in set.output) {
if (x.exists()) {
for (y in x.listFiles()) {
def name = y.name
if (!name.contains('$') && name.contains(".class")) {
def klass = ucl.loadClass(y.name.replace(".class", ""))
try {
def mainMethod = klass.getMethod("main")
javaexec {
classpath set.runtimeClasspath
def className = y.name.replace(".class", "")
main = className
jvmArgs += "-DtakeScreenshot=true"
jvmArgs += "-DscreenshotPath=${sub.name}/images/${className}.png"
}
} catch (e) {
// skip?
}
}
}
}
}
}
}
}
}