Files
orx/build.gradle
2021-08-31 15:22:31 +02:00

246 lines
7.4 KiB
Groovy

import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
classpath "com.netflix.nebula:nebula-release-plugin:15.3.1"
}
}
plugins {
// remember to update all the versions here when upgrading kotlin version
id 'org.jetbrains.kotlin.jvm' apply false
id 'org.jetbrains.kotlin.multiplatform' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.30' apply false
}
def multiplatformModules = [
"orx-camera",
"orx-color",
"orx-compositor",
"orx-easing",
"orx-fx",
"orx-gradient-descent",
"orx-image-fit",
"orx-no-clear",
"orx-noise",
"orx-parameters",
"orx-shade-styles",
"orx-shader-phrases",
"orx-shapes",
"orx-quadtree",
]
project.ext {
kotlinApiVersion = '1.4'
kotlinLanguageVersion = '1.4'
kotlinVersion = '1.5.30'
kotlinLoggingVersion = '2.0.8'
kotlinxSerializationVersion = '1.1.0'
spekVersion = '2.0.15'
kluentVersion = '1.65'
jsoupVersion = '1.13.1'
kotestVersion = '4.4.3'
junitJupiterVersion = '5.7.1'
}
def openrndrUseSnapshot = true
apply plugin: 'org.jetbrains.dokka'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
project.ext {
openrndrVersion = openrndrUseSnapshot? "0.5.1-SNAPSHOT" : "0.4.0"
jvmTarget = "1.8"
kotlinVersion = "1.5.30"
kotlinApiVersion = "1.4"
spekVersion = "2.0.15"
libfreenectVersion = "0.5.7-1.5.5"
librealsense2Version = "2.40.0-1.5.5"
gsonVersion = "2.8.6"
antlrVersion = "4.9.2"
tensorflowVersion = "0.3.2"
mklDnnVersion = "0.21.5-1.5.5"
}
allprojects {
group 'org.openrndr.extra'
repositories {
mavenCentral()
if (openrndrUseSnapshot) {
mavenLocal()
}
maven {
url = "https://maven.openrndr.org"
}
}
}
switch (org.gradle.internal.os.OperatingSystem.current()) {
case org.gradle.internal.os.OperatingSystem.WINDOWS:
project.ext.openrndrOS = "windows"
break
case org.gradle.internal.os.OperatingSystem.LINUX:
project.ext.openrndrOS = "linux-x64"
break
case org.gradle.internal.os.OperatingSystem.MAC_OS:
project.ext.openrndrOS = "macos"
break
}
dokka {
moduleName = "$rootProject.name"
outputDirectory = "$buildDir/docs"
outputFormat = "html"
includes = ['Module.md']
sourceDirs = files(subprojects.collect { p -> new File(p.projectDir, "/src/main/kotlin") })
}
task buildMainReadme {
doFirst {
def subProjects = project.subprojects
//.findAll { !it.name.contains("kinect-common") && !it.name.contains
// ("kinect-v1-") }
// Load README.md and find [begin, end] section to replace
def mainReadme = file("README.md")
def lines = mainReadme.readLines()
def begin = lines.findIndexOf { it == "<!-- __orxListBegin__ -->" }
def end = lines.findIndexOf { it == "<!-- __orxListEnd__ -->" }
if (begin == -1 || end == -1) {
println("Comments for orx list generation not found in README.md!")
return
}
def header = lines.subList(0, begin + 1)
def footer = lines.subList(end, lines.size())
def newReadme = []
for (line in header) {
newReadme.add(line)
}
// Search for the description at the top of the readme.
// Skip the hash character from the headline, then start
// on the next line and continue until the next empty line.
// Don't fall into Windows line breaks.
def descriptionRx = ~/(?s)\#.*?\n(.+?)\n\r?\n/
// Note: the readme needs an empty line after the description
def orxMultiplatform = []
def orxJVMOnly = []
// Build orx list
for (sub in subProjects) {
def orxReadmeFile = sub.file("README.md")
if (orxReadmeFile.exists()) {
def orxReadmeText = orxReadmeFile.getText()
orxReadmeText.find(descriptionRx) {
description ->
def trimmedDescription = description[1].trim() //.strip() supports unicode, java11 only
.replace("\n", " ").replace("\r", "")
def path = sub.path.substring(1).replace(":", "/")
if (path.startsWith("orx-jvm")) {
orxJVMOnly.add("| [`${sub.name}`]($path/) " +
"| $trimmedDescription |")
} else {
orxMultiplatform.add("| [`${sub.name}`]($path/) " +
"| $trimmedDescription |")
}
}
} else {
println("${sub.name}/README.md not found!")
}
}
newReadme.add("\n## Multiplatform\n")
newReadme.add("| name" + "&nbsp;" * 36 + " | description |")
newReadme.add("| --- | --- |")
newReadme.addAll(orxMultiplatform)
newReadme.add("\n## JVM only\n")
newReadme.add("| name" + "&nbsp;" * 36 + " | description |")
newReadme.add("| --- | --- |")
newReadme.addAll(orxJVMOnly)
for (line in footer) {
newReadme.add(line)
}
// Write result
if (mainReadme.exists()) {
mainReadme.delete()
}
mainReadme.write(newReadme.join("\n"))
}
}
configure(allprojects.findAll { !multiplatformModules.contains(it.name) }) {
// apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'maven-publish'
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
dependencies {
// Note: kotlin-logging and kotlinx-coroutines-core are loaded
// too early and their versions cannot be parametrized
implementation 'io.github.microutils:kotlin-logging:2.0.6'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "org.openrndr:openrndr-application:$openrndrVersion"
implementation "org.openrndr:openrndr-math:$openrndrVersion"
testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spekVersion"
testImplementation "org.amshove.kluent:kluent:$kluentVersion"
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
testRuntimeOnly "org.spekframework.spek2:spek-runner-junit5:$spekVersion"
testRuntimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
}
test {
useJUnitPlatform {
includeEngines 'spek2'
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
javadoc {
options.addBooleanOption 'Xdoclint:none', true
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi"]
}
}
configure(allprojects.findAll { it.name != "openrndr-demos" }) {
apply plugin: 'maven-publish'
apply plugin: 'nebula.release'
}
//collectScreenshots.dependsOn {
// project.subprojects.findAll { it.sourceSets.hasProperty("demo") }.collect { it.tasks.demoClasses }
//}