Use buildSrc to deduplicate build logic (#262)

This commit is contained in:
Vechro
2022-08-25 12:52:24 +03:00
committed by GitHub
parent 2479f9fe9a
commit f9130d9108
98 changed files with 1091 additions and 1683 deletions

View File

@@ -1,21 +1,11 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// root build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
classpath "com.netflix.nebula:nebula-release-plugin:16.0.0"
}
plugins {
alias(libs.plugins.nebula.release) apply false
alias(libs.plugins.gradle.nexus.publish)
id("org.openrndr.extra.convention.dokka")
}
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 "io.github.gradle-nexus.publish-plugin" version "1.1.0"
repositories {
mavenCentral()
}
def multiplatformModules = [
@@ -41,33 +31,7 @@ def multiplatformModules = [
def doNotPublish = ["openrndr-demos"]
apply plugin: 'org.jetbrains.dokka'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
def openrndrUseSnapshot = isReleaseVersion
allprojects {
group 'org.openrndr.extra'
repositories {
mavenCentral()
if (openrndrUseSnapshot) {
mavenLocal()
}
maven {
url = "https://maven.openrndr.org"
}
}
}
dokka {
moduleName = "$rootProject.name"
outputDirectory = "$buildDir/docs"
outputFormat = "html"
includes = ['Module.md']
sourceDirs = files(subprojects.collect { p -> new File(p.projectDir, "/src/main/kotlin") })
}
def isReleaseVersion = !version.endsWith("SNAPSHOT")
task buildMainReadme {
doFirst {
@@ -159,7 +123,6 @@ configure(allprojects.findAll { !doNotPublish.contains(it.name) && (multiplatfor
archiveClassifier = "javadoc"
}
publishing {
publications {
matching { it.name == "jvm" }.all { p ->
@@ -168,6 +131,11 @@ configure(allprojects.findAll { !doNotPublish.contains(it.name) && (multiplatfor
}
publications {
all {
versionMapping {
allVariants {
fromResolutionOf("allSourceSetsRuntimeDependenciesMetadata")
}
}
pom {
name = "$project.name"
description = "$project.name"
@@ -214,20 +182,15 @@ configure(allprojects.findAll { !doNotPublish.contains(it.name) && (multiplatfor
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
sign publishing.publications
}
}
// publishable && JVM only
configure(allprojects.findAll { !doNotPublish.contains(it.name) && !multiplatformModules.contains(it.name) }) {
// apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'maven-publish'
apply plugin: 'nebula.release'
apply plugin: 'signing'
def proj = it
println proj
java {
withJavadocJar()
withSourcesJar()
@@ -236,6 +199,11 @@ configure(allprojects.findAll { !doNotPublish.contains(it.name) && !multiplatfor
publications {
maven(MavenPublication) {
from components.java
versionMapping {
allVariants {
fromResolutionOf("default")
}
}
groupId = "org.openrndr.extra"
artifactId = "$project.name"
description = "$project.name"
@@ -286,37 +254,10 @@ configure(allprojects.findAll { !doNotPublish.contains(it.name) && !multiplatfor
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
sign publishing.publications
}
dependencies {
implementation libs.kotlin.logging
implementation libs.kotlin.coroutines
implementation libs.kotlin.stdlib
implementation libs.openrndr.application
implementation libs.openrndr.math
testImplementation libs.spek.dsl
testImplementation libs.kluent
testImplementation libs.kotlin.test
testRuntimeOnly libs.spek.junit5
testRuntimeOnly libs.kotlin.reflect
}
test {
useJUnitPlatform {
includeEngines 'spek2'
}
}
javadoc {
options.addBooleanOption 'Xdoclint:none', true
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi"]
}
}
group = "org.openrndr"
group = "org.openrndr.extra"
nexusPublishing {
repositories {
sonatype {
@@ -331,29 +272,7 @@ nexusPublishing {
subprojects {
// Equivalent Kotlin is: tasks.register<DependencyReportTask>("dependenciesAll") { ...
tasks.register("dependenciesAll", DependencyReportTask) {
group = "help"
group = HelpTasksPlugin.HELP_GROUP
description = "Displays all dependencies, including subprojects."
}
kotlin {
// https://youtrack.jetbrains.com/issue/KT-43095/Add-support-for-Java-Toolchain-to-the-Gradle-plugin#focus=Comments-27-5192573.0-0
jvmToolchain { toolchain ->
(toolchain as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(libs.versions.jvmTarget.get()))
}
tasks.withType(KotlinCompile).configureEach {
kotlinOptions.jvmTarget = libs.versions.jvmTarget.get()
kotlinOptions.apiVersion = libs.versions.kotlinApi.get()
}
}
}
//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 }
//}
}