Skip to content

Commit

Permalink
Fix GH workflows.
Browse files Browse the repository at this point in the history
WIP kradle.
  • Loading branch information
buijs-dev committed Mar 15, 2024
1 parent 187554d commit d294ec0
Show file tree
Hide file tree
Showing 26 changed files with 224 additions and 128 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 11
java-version: 17
cache: gradle
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.0.5'
channel: 'stable'
- uses: gradle/gradle-build-action@v2.4.2
with:
gradle-version: 7.4.2
gradle-version: 8.3
arguments: clean build koverMergedXmlReport -p "lib"

- uses: codecov/codecov-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dokka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 11
java-version: 17
- name: 'setup gradle'
uses: gradle/gradle-build-action@v2.4.2
with:
gradle-version: 7.4.2
gradle-version: 8.3
- name: 'setup flutter'
uses: subosito/flutter-action@v2
with:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/kradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 11
java-version: 17
cache: gradle
- name: 'build distribution'
uses: gradle/gradle-build-action@v2.4.2
with:
gradle-version: 7.4.2
arguments: clean build -p "lib/kradle"
gradle-version: 8.3b/kradle"
- name: 'copy jar to kradle folder'
run: cp ./lib/kradle/build/libs/kradle-wrapper.jar kradle/lib
- name: 'create zip file'
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGELOG

## v2024.1.1.beta

## v2023.3.1.beta
- Refactored task module to package in kore.
- Removed task module from BOM e.a.
Expand All @@ -15,8 +17,6 @@
- Uses [klutter-dart](https://pub.dev/packages/klutter) version 1.0.0.
- Uses [klutter-dart-ui](https://pub.dev/packages/klutter_ui) version 1.0.0.

## v2023.3.1.beta

## v2023.1.1.beta
- Added support for request parameters.
- Added support for streaming data from platform to ui (using EventChannel).
Expand Down
4 changes: 2 additions & 2 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.dokka.gradle.DokkaTask

plugins {
kotlin("jvm")
id("org.jetbrains.dokka") version "1.6.10"
id("org.jetbrains.dokka") version "1.9.20"
id("org.jetbrains.kotlinx.kover") version "0.5.1"
id("klutter")
}
Expand Down Expand Up @@ -57,7 +57,7 @@ tasks.withType<DokkaTask>().configureEach {
}

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(layout.buildDirectory.dir("dokkaSite").map { it.asFile })
outputDirectory.set(layout.buildDirectory.dir("dokkaSite"))
}

tasks.koverMergedXmlReport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.PluginContainer
import org.gradle.api.tasks.TaskContainer
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

/**
* Gradle plugin for Klutter Framework.
Expand All @@ -45,9 +46,25 @@ class KlutterGradlePlugin: Plugin<Project> {
tasks.registerTasks()
plugins.applyKspPlugin()
extensions.add("klutter", KlutterExtension(project))
val ext = project.extensions.getByType(KspExtension::class.java)
val ksp = project.extensions.getByType(KspExtension::class.java)
project.afterEvaluate {
ext.arg(kspArgumentKlutterProjectFolder, project.rootDir.absolutePath)
// KMP
val kmp = try {
project.extensions.getByType(KotlinMultiplatformExtension::class.java)
} catch (_: Exception) {
null
}

if (kmp != null) {
kmp.sourceSets
.getByName("commonMain")
.kotlin
.srcDir(layout.buildDirectory.file("generated/ksp/metadata/commonMain/kotlin"))
tasks.bindPostBuildTasks()
}

// KSP
ksp.arg(kspArgumentKlutterProjectFolder, project.rootDir.absolutePath)
}
}
}
Expand All @@ -64,11 +81,26 @@ private fun PluginContainer.applyKspPlugin() {
* Register the custom Klutter tasks.
*/
private fun TaskContainer.registerTasks() {
register("klutterCopyAarFile", CopyAndroidAarFileGradleTask::class.java)
register("klutterCopyFramework", CopyIosFrameworkGradleTask::class.java)
register("klutterGetKradle", GetKradleTask::class.java)
register("klutterGetDartProtoc", GetDartProtocExeGradleTask::class.java)
register("klutterGetProtoc", GetProtocGradleTask::class.java)
register("klutterCompileProtoSchema", CompileProtoSchemaGradleTask::class.java)
register("klutterCleanGeneratedProtoExt", CleanProtoExtensionsGradleTask::class.java)
register(CopyAndroidAarFileGradleTask.gradleTaskName, CopyAndroidAarFileGradleTask::class.java)
register(CopyIosFrameworkGradleTask.gradleTaskName, CopyIosFrameworkGradleTask::class.java)
register(GetKradleTask.gradleTaskName, GetKradleTask::class.java)
register(GetDartProtocExeGradleTask.gradleTaskName, GetDartProtocExeGradleTask::class.java)
register(GetProtocGradleTask.gradleTaskName, GetProtocGradleTask::class.java)
register(CompileProtoSchemaGradleTask.gradleTaskName, CompileProtoSchemaGradleTask::class.java)
register(GenerateFlutterLibGradleTask.gradleTaskName, GenerateFlutterLibGradleTask::class.java)
}

private fun TaskContainer.bindPostBuildTasks() {
getByName("build").setFinalizedBy(
listOf(CopyAndroidAarFileGradleTask.gradleTaskName,
CompileProtoSchemaGradleTask.gradleTaskName,
"assemblePlatformReleaseXCFramework",
"klutterGenerateProtoSchemas"
))

getByName("assemblePlatformReleaseXCFramework")
.setFinalizedBy(listOf(getByName(CopyIosFrameworkGradleTask.gradleTaskName)))

getByName("klutterGenerateProtoSchemas")
.setFinalizedBy(listOf("klutterCompileProtoSchemas"))
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ import dev.buijs.klutter.kore.tasks.codegen.CompileProtoSchemaTask

internal open class CompileProtoSchemaGradleTask: AbstractTask() {

companion object {
val gradleTaskName = "klutterCompileProtoSchemas"
}

init {
super.dependsOn(GetDartProtocExeGradleTask.gradleTaskName, GetProtocGradleTask.gradleTaskName)
super.finalizedBy(GenerateFlutterLibGradleTask.gradleTaskName)
}

override fun klutterTask(): KlutterTask =
CompileProtoSchemaTask(super.project().root.folder)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import dev.buijs.klutter.kore.tasks.CopyXCFrameworkTask
* Execute task [CopyAndroidAarFileGradleTask] from Gradle.
*/
internal open class CopyAndroidAarFileGradleTask: AbstractTask() {
companion object {
val gradleTaskName = "klutterCopyAarFile"
}

override fun klutterTask() = CopyAarFileTask(
pathToRoot = project.rootDir,
pluginName = project.klutterExtension().plugin?.name,
Expand All @@ -38,6 +42,9 @@ internal open class CopyAndroidAarFileGradleTask: AbstractTask() {
* Execute task [CopyXCFrameworkTask] from Gradle.
*/
internal open class CopyIosFrameworkGradleTask: AbstractTask() {
companion object {
val gradleTaskName = "klutterCopyFramework"
}
override fun klutterTask() = CopyXCFrameworkTask(
pathToRoot = project.rootDir,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2021 - 2024 Buijs Software
/* Copyright (c) 2021 - 2023 Buijs Software
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,15 +19,23 @@
* SOFTWARE.
*
*/
package dev.buijs.klutter.kore.tasks.codegen
package dev.buijs.klutter.gradle.tasks

import dev.buijs.klutter.kore.KlutterTask
import java.io.File
import dev.buijs.klutter.kore.common.verifyExists
import dev.buijs.klutter.kore.tasks.codegen.GenerateFlutterLibTask

class CleanProtoExtensionsTask(
private val sourceFolder: File,
) : KlutterTask, GenerateCodeAction {
override fun run() {
sourceFolder.listFiles { _, name -> name.startsWith("\$protogen") }?.forEach { file -> file.delete() }
internal open class GenerateFlutterLibGradleTask: AbstractTask() {
companion object {
val gradleTaskName = "klutterGenerateFlutterLib"
}
override fun klutterTask(): KlutterTask {
val project = project()

return GenerateFlutterLibTask(
pluginName = project.root.pluginName,
root = project.root,
srcFolder = project.root.pathToLibFolder.resolve("src").verifyExists()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ import dev.buijs.klutter.kore.tasks.GetDartProtocExeTask
* Execute task [GetDartProtocExeTask] from Gradle.
*/
internal open class GetDartProtocExeGradleTask: AbstractTask() {

companion object {
val gradleTaskName = "klutterGetDartProtoc"
}

override fun klutterTask(): KlutterTask = GetDartProtocExeTask()
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ internal val kradlewBat: InputStream
* Download Kradle CLI Tool.
*/
internal open class GetKradleTask: AbstractTask() {

companion object {
val gradleTaskName = "klutterGetKradle"
}

override fun klutterTask() =
project.rootProject.projectDir.toGetKradleTask()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ package dev.buijs.klutter.gradle.tasks

import dev.buijs.klutter.kore.KlutterTask
import dev.buijs.klutter.kore.project.kradleHome
import dev.buijs.klutter.kore.project.kradleYaml
import dev.buijs.klutter.kore.tasks.DownloadProtocTask
import dev.buijs.klutter.kore.tasks.GetDartProtocExeTask
import java.io.File

/**
* Execute task [DownloadProtocTask] from Gradle.
*/
internal open class GetProtocGradleTask: AbstractTask() {
companion object {
val gradleTaskName = "klutterGetProtoc"
}

override fun klutterTask(): KlutterTask {
val project = super.project()
return DownloadProtocTask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.kotlintest.shouldBe
import io.kotlintest.shouldNotBe
import io.kotlintest.specs.WordSpec
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.file.ProjectLayout
import org.gradle.api.plugins.ExtensionContainer
import org.gradle.api.plugins.PluginContainer
import org.gradle.api.tasks.TaskContainer
Expand Down Expand Up @@ -58,8 +59,12 @@ internal class KlutterGradlePluginTest: WordSpec({
val subTemp = temp.resolve("foo")
subTemp.mkdir()

val layout: ProjectLayout = mock {
whenever(it.buildDirectory).thenAnswer { temp }
}

val project: org.gradle.api.Project = mock {
whenever(it.buildDir).thenAnswer { temp }
whenever(it.layout).thenAnswer { layout }
whenever(it.projectDir).thenAnswer { subTemp }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import java.awt.Graphics
import javax.swing.JPanel

private val knownKlutterBOMVersions = setOf(
"2024.1.1.beta",
"2023.3.1.beta",
"2023.2.2.beta",
"2023.2.1.beta",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ package dev.buijs.klutter.kore.project
import com.fasterxml.jackson.annotation.JsonAutoDetect
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.*
import com.fasterxml.jackson.databind.cfg.CoercionAction
import com.fasterxml.jackson.databind.cfg.CoercionInputShape
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
Expand All @@ -40,17 +38,17 @@ import java.io.File
/**
* The version of Klutter Gradle Executable Tool.
*/
const val klutterBomVersion = "2023.3.1.beta"
const val klutterBomVersion = "2024.1.1.beta"

/**
* The version of the klutter Pub Plugin.
*/
const val klutterPubVersion = "2.0.0"
const val klutterPubVersion = "2.1.0"

/**
* The version of the klutter-ui Pub Plugin.
*/
const val klutterUIPubVersion = "1.0.1"
const val klutterUIPubVersion = "1.1.0"

/**
* The version of the squint_json Pub Plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ package dev.buijs.klutter.kore.tasks.codegen

import dev.buijs.klutter.kore.KlutterTask
import dev.buijs.klutter.kore.common.maybeCreate
import dev.buijs.klutter.kore.common.verifyExists
import dev.buijs.klutter.kore.common.maybeCreateFolder
import dev.buijs.klutter.kore.common.write
import dev.buijs.klutter.kore.templates.ProtobufExtensions
import java.io.File

const val protoGenMarker = "ProtocolBufferGenerated"

fun GenerateCodeOptions.toGenerateProtoExtensionsTask() =
GenerateProtoExtensionsTask(project.platform.source(), responseClassNames)
GenerateProtoExtensionsTask(project.platform.folder
.resolve("build")
.resolve("generated")
.resolve("ksp")
.resolve("metadata")
.resolve("commonMain")
.resolve("kotlin")
, responseClassNames)

class GenerateProtoExtensionsTask(
private val sourceFolder: File,
Expand All @@ -46,10 +55,9 @@ class GenerateProtoExtensionsTask(
val className = fqdn.substringAfterLast(".")

sourceFolder
.resolve("kotlin")
.resolve(pathToPackage)
.verifyExists()
.resolve("\$protogen$className.kt")
.maybeCreateFolder()
.resolve("$protoGenMarker$className.kt")
.maybeCreate()
.write(ProtobufExtensions(packageName, className))
}
Expand Down
Loading

0 comments on commit d294ec0

Please sign in to comment.