Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Use version catalog + build.gradle.kts -> build.gradle to improve bui…
Browse files Browse the repository at this point in the history
…ld startup (#590)
  • Loading branch information
soywiz authored Apr 15, 2022
1 parent 73b7dfd commit 00a270e
Show file tree
Hide file tree
Showing 52 changed files with 714 additions and 974 deletions.
3 changes: 2 additions & 1 deletion .github/actions/gradle-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ runs:
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle.properties', 'gradle/wrapper/gradle-wrapper.properties') }}
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle.properties', 'gradle/libs.versions.toml', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: webiny/action-post-run@2.0.1
id: gradle-cache-cleanup
with:
run: |
./gradlew --stop
rm -rf ~/.gradle/caches/modules-2/modules-2.lock
rm -rf ~/.gradle/caches/modules-2/gc.properties
rm -rf ~/.konan/cache
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 0 additions & 19 deletions @old/korte-vertx/build.gradle.old

This file was deleted.

26 changes: 11 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ val useMimalloc = true

val kotlinVersion: String by project
val realKotlinVersion = (System.getenv("FORCED_KOTLIN_VERSION") ?: kotlinVersion)
val coroutinesVersion: String by project
val nodeVersion: String by project
val jnaVersion: String by project
val androidBuildGradleVersion: String by project
val kotlinSerializationVersion: String by project

Expand Down Expand Up @@ -665,21 +663,20 @@ samples {

if (rootProject.tasks.findByName(npmInstallEsbuild) == null) {
rootProject.tasks.create(npmInstallEsbuild, Exec::class) {
val task = this
task.dependsOn("kotlinNodeJsSetup")
task.onlyIf { !esbuildCmdCheck.exists() && !esbuildCmd.exists() }
dependsOn("kotlinNodeJsSetup")
onlyIf { !esbuildCmdCheck.exists() && !esbuildCmd.exists() }

val esbuildVersion = esbuildVersion
task.doFirst {
doFirst {
val npmCmd = arrayOf(
File(env.nodeExecutable),
File(env.nodeDir, "lib/node_modules/npm/bin/npm-cli.js").takeIf { it.exists() }
?: File(env.nodeDir, "node_modules/npm/bin/npm-cli.js").takeIf { it.exists() }
?: error("Can't find npm-cli.js in ${env.nodeDir} standard folders")
)

task.environment("PATH", ENV_PATH)
task.commandLine(*npmCmd, "-g", "install", "esbuild@$esbuildVersion", "--prefix", esbuildFolder, "--scripts-prepend-node-path", "true")
environment("PATH", ENV_PATH)
commandLine(*npmCmd, "-g", "install", "esbuild@$esbuildVersion", "--prefix", esbuildFolder, "--scripts-prepend-node-path", "true")
}
}
}
Expand All @@ -696,7 +693,6 @@ samples {
}
val compileDevelopmentExecutableKotlinJs = "compileDevelopmentExecutableKotlinJs"
val runJs by creating(Exec::class) {
val task = this
group = "run"
//dependsOn("jsBrowserDevelopmentRun")
dependsOn(browserEsbuildResources)
Expand All @@ -709,10 +705,10 @@ samples {
}

val output = File(wwwFolder, "${project.name}.js")
task.inputs.file(jsPath)
task.outputs.file(output)
inputs.file(jsPath)
outputs.file(output)
//task.environment("PATH", ENV_PATH)
task.commandLine(ArrayList<Any>().apply {
commandLine(ArrayList<Any>().apply {
add(esbuildCmd)
//add("--watch",)
add("--bundle")
Expand All @@ -724,7 +720,7 @@ samples {
//if (run) add("--servedir=$wwwFolder")
})

task.doLast {
doLast {
runServer(!project.gradle.startParameter.isContinuous)
}
}
Expand Down Expand Up @@ -967,8 +963,8 @@ object BuildVersions {
const val GIT = "$gitVersion"
const val KOTLIN = "$realKotlinVersion"
const val NODE_JS = "$nodeVersion"
const val JNA = "$jnaVersion"
const val COROUTINES = "$coroutinesVersion"
const val JNA = "${libs.versions.jna.get()}"
const val COROUTINES = "${libs.versions.kotlinx.coroutines.get()}"
const val ANDROID_BUILD = "$androidBuildGradleVersion"
const val KOTLIN_SERIALIZATION = "$kotlinSerializationVersion"
const val KRYPTO = "$projectVersion"
Expand Down
28 changes: 0 additions & 28 deletions buildSrc/build.gradle.kts.old

This file was deleted.

87 changes: 87 additions & 0 deletions buildSrc/src/main/kotlin/com/soywiz/korlibs/NativeTools.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.soywiz.korlibs

import com.soywiz.korlibs.modules.*
import org.gradle.api.*

object NativeTools {
@JvmStatic
fun configureCInteropWin32(project: Project, name: String) {
if (project.doEnableKotlinNative) {
project.kotlin {
for (target in nativeTargets(project)) {
if (target.isWin) {
target.compilations["main"].cinterops {
maybeCreate(name)
}
}
}
}
}
}


@JvmStatic
fun configureCInteropLinux(project: Project, name: String) {
if (project.doEnableKotlinNative) {
project.kotlin {
for (target in nativeTargets(project)) {
if (target.isLinux) {
target.compilations["main"].cinterops {
maybeCreate(name)
}
}
}
}
}
}

@JvmStatic
fun configureAllCInterop(project: Project, name: String) {
if (project.doEnableKotlinNative) {
project.kotlin {
for (target in allNativeTargets(project)) {
target.compilations["main"].cinterops {
maybeCreate(name)
}
}
}
}
}

@JvmStatic
fun configureAndroidDependency(project: Project, dep: Any) {
project.dependencies {
project.afterEvaluate {
if (project.configurations.findByName("androidMainApi") != null) {
add("androidMainApi", dep)
}
}
}
}

@JvmStatic
fun configureExtraSourceSets(project: Project) {
project.afterEvaluate {
kotlin {
for (targetName in listOf("linuxX64", "linuxArm32Hfp", "macosX64", "macosArm64")) {
//println("targetName=$targetName")
val target = targets.findByName(targetName) ?: continue
//println("target=$target")
val folder = project.file("src/${targetName}Main/kotlin")
//println(" - $folder")
target.compilations["main"].defaultSourceSet.kotlin.srcDir(folder)
}
}
}
}

@JvmStatic
fun groovyConfigurePublishing(project: Project, multiplatform: Boolean) {
project.configurePublishing(multiplatform = multiplatform)
}

@JvmStatic
fun groovyConfigureSigning(project: Project) {
project.configureSigning()
}
}
6 changes: 1 addition & 5 deletions e2e-sample/build.gradle.kts → e2e-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import com.soywiz.korge.gradle.*

buildscript {
val korgePluginVersion: String by project

repositories {
mavenLocal()
mavenCentral()
Expand All @@ -14,7 +10,7 @@ buildscript {
}
}

apply<KorgeGradlePlugin>()
apply plugin: "com.soywiz.korge"

korge {
id = "com.sample.demo"
Expand Down
13 changes: 0 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ version=2.0.0.999

kotlinVersion=1.6.20

# Required for intellij plugin to work. When using 1.6.0 there is an error: java.util.ServiceConfigurationError: kotlinx.coroutines.CoroutineExceptionHandler: com.intellij.openapi.application.impl.CoroutineExceptionHandlerImpl not a subtype
coroutinesVersion=1.6.1

kotlinSerializationVersion=1.3.2
#kotlin.native.binary.memoryModel=experimental

Expand All @@ -15,21 +12,11 @@ nodeVersion=16.9.1
#kotlinSerializationVersion=1.3.0

androidBuildGradleVersion=7.0.3
#proguardVersion=7.2.0-beta2
proguardVersion=6.2.2

jnaVersion=5.9.0

jcodecVersion=0.2.5

gradlePublishPluginVersion=0.14.0
closureCompilerVersion=v20210808
#closureCompilerVersion=v20210601

playServicesAdsVersion=16.0.0
playServicesGamesVersion=20.0.1
playServicesAuthVersion=18.1.0
playServicesBillingVersion=3.0.1
android.useAndroidX=true

enableKotlinNative=true
Expand Down
19 changes: 19 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[versions]
jna = "5.11.0"
jcodec = "0.2.5"
proguard-gradle = "6.2.2" # 7.2.0-beta2
kotlinx-coroutines = "1.6.1"

[libraries]
jna-core = { module = "net.java.dev.jna:jna", version.ref = "jna" }
jna-platform = { module = "net.java.dev.jna:jna-platform", version.ref = "jna" }
jcodec-core = { module = "org.jcodec:jcodec", version.ref = "jcodec" }
proguard-gradle = { module = "net.sf.proguard:proguard-gradle", version.ref = "proguard-gradle" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }

[bundles]
jna = ["jna-core", "jna-platform"]

#[plugins]
#jmh = { id = "me.champeau.jmh", version = "0.6.5" }
4 changes: 4 additions & 0 deletions kmem/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
description = "Memory utilities for Kotlin"

dependencies {
}
19 changes: 0 additions & 19 deletions kmem/build.gradle.kts

This file was deleted.

9 changes: 9 additions & 0 deletions korau/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description = "Portable Audio library for Kotlin"

com.soywiz.korlibs.NativeTools.configureAllCInterop(project, "minimp3")
com.soywiz.korlibs.NativeTools.configureAllCInterop(project, "stb_vorbis")

dependencies {
add("commonMainApi", project(":korio"))
add("jvmMainApi", libs.bundles.jna)
}
23 changes: 0 additions & 23 deletions korau/build.gradle.kts

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 00a270e

Please sign in to comment.