├── .github ├── FUNDING.yml ├── assets │ └── metadata │ │ └── icon │ │ ├── banner.png │ │ ├── icon.png │ │ ├── klutter_logo.png │ │ ├── klutter_logo_animated.gif │ │ ├── klutter_logo_animated2.gif │ │ ├── klutter_logo_animated3.gif │ │ └── logo_animated.gif ├── badges │ ├── ccvbadge.svgnotusedatm │ └── license.svg └── workflows │ ├── codecov.yml │ └── dokka.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build.gradle.kts ├── codecov.yml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib-build ├── build.gradle.kts └── src │ └── main │ ├── kotlin │ └── dev │ │ └── buijs │ │ └── klutter │ │ └── KlutterInternalPlugin.kt │ └── resources │ ├── publish.properties │ └── repository.properties ├── lib-test ├── build.gradle.kts ├── integrationtest.md ├── module.md └── src │ ├── main │ ├── groovy │ │ └── dev │ │ │ └── buijs │ │ │ └── klutter │ │ │ └── kore │ │ │ └── test │ │ │ └── TestUtil.groovy │ ├── kotlin │ │ └── dev │ │ │ └── buijs │ │ │ └── klutter │ │ │ └── kore │ │ │ └── test │ │ │ ├── TestException.kt │ │ │ ├── TestPlugin.kt │ │ │ └── TestResource.kt │ └── resources │ │ ├── android_adapter │ │ ├── android_app_manifest │ │ ├── android_main_activity │ │ ├── android_plugin_class │ │ ├── build_gradle_plugin │ │ ├── flutter_plugin_library │ │ ├── ios_swift_plugin │ │ ├── klutter_android_main_activity │ │ ├── kompose_android_plugin_class │ │ ├── kompose_build_gradle │ │ ├── kompose_feed │ │ ├── kompose_home │ │ ├── kompose_root_build_gradle │ │ ├── kompose_settings_gradle │ │ ├── platform_source_code │ │ ├── plugin_ios_podspec │ │ ├── plugin_ios_podspec_excluded │ │ ├── plugin_platform_podspec │ │ ├── plugin_pubspec │ │ └── settings_gradle_plugin │ └── test │ └── groovy │ └── dev │ └── buijs │ └── klutter │ └── kore │ └── test │ ├── LocalE2ESpec.groovy │ └── TestResourceSpec.groovy ├── lib ├── annotations │ ├── annotations.podspec │ ├── build.gradle.kts │ ├── module.md │ └── src │ │ ├── androidMain │ │ └── kotlin │ │ │ └── dev │ │ │ └── buijs │ │ │ └── klutter │ │ │ └── annotations │ │ │ └── KlutterAnnotations.kt │ │ ├── commonMain │ │ └── kotlin │ │ │ └── dev │ │ │ └── buijs │ │ │ └── klutter │ │ │ └── annotations │ │ │ └── KlutterAnnotations.kt │ │ ├── iosMain │ │ └── kotlin │ │ │ └── dev │ │ │ └── buijs │ │ │ └── klutter │ │ │ └── annotations │ │ │ └── KlutterAnnotations.kt │ │ └── jvmMain │ │ └── kotlin │ │ └── dev │ │ └── buijs │ │ └── klutter │ │ └── annotations │ │ └── KlutterAnnotations.kt ├── bill-of-materials │ └── build.gradle.kts ├── build.gradle.kts ├── compiler │ ├── build.gradle.kts │ ├── module.md │ └── src │ │ ├── main │ │ ├── kotlin │ │ │ └── dev │ │ │ │ └── buijs │ │ │ │ └── klutter │ │ │ │ └── compiler │ │ │ │ ├── processor │ │ │ │ ├── Processor.kt │ │ │ │ ├── ProcessorOptions.kt │ │ │ │ └── ProcessorProvider.kt │ │ │ │ ├── scanner │ │ │ │ ├── ControllerOutput.kt │ │ │ │ ├── ControllerResults.kt │ │ │ │ ├── ControllerScanner.kt │ │ │ │ ├── ControllerTypes.kt │ │ │ │ ├── EventResults.kt │ │ │ │ ├── EventScanner.kt │ │ │ │ ├── ResponseOutput.kt │ │ │ │ ├── ResponseResults.kt │ │ │ │ └── ResponseScanner.kt │ │ │ │ ├── validator │ │ │ │ ├── ControllerValidator.kt │ │ │ │ ├── EventValidator.kt │ │ │ │ ├── ResponseValidator.kt │ │ │ │ ├── Shared.kt │ │ │ │ └── ValidationResult.kt │ │ │ │ └── wrapper │ │ │ │ ├── KAEvent.kt │ │ │ │ ├── KCController.kt │ │ │ │ ├── KCLogger.kt │ │ │ │ └── KCResponse.kt │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── com.google.devtools.ksp.processing.SymbolProcessorProvider │ │ └── test │ │ └── groovy │ │ └── dev │ │ └── buijs │ │ └── klutter │ │ └── compiler │ │ ├── processor │ │ └── ProcessorProviderSpec.groovy │ │ ├── scanner │ │ ├── ControllerScannerSpec.groovy │ │ ├── EventScannerSpec.groovy │ │ └── ResponseScannerSpec.groovy │ │ └── validator │ │ ├── ControllerValidatorSpec.groovy │ │ └── ResponseValidatorSpec.groovy ├── gradle │ ├── build.gradle.kts │ ├── module.md │ └── src │ │ ├── main │ │ ├── kotlin │ │ │ └── dev │ │ │ │ └── buijs │ │ │ │ └── klutter │ │ │ │ └── gradle │ │ │ │ ├── KlutterGradlePlugin.kt │ │ │ │ ├── dsl │ │ │ │ ├── DependencyUtils.kt │ │ │ │ ├── KlutterExtension.kt │ │ │ │ ├── KlutterFeature.kt │ │ │ │ ├── KlutterPluginDSL.kt │ │ │ │ ├── KlutterVersion.kt │ │ │ │ └── KotlinMultiplatformUtils.kt │ │ │ │ └── tasks │ │ │ │ ├── AbstractTask.kt │ │ │ │ ├── CodeGenTasks.kt │ │ │ │ ├── CopyTasks.kt │ │ │ │ ├── GetKradleGradleTask.kt │ │ │ │ └── ProtoTasks.kt │ │ └── resources │ │ │ └── publish.properties │ │ └── test │ │ └── groovy │ │ └── dev │ │ └── buijs │ │ └── klutter │ │ └── gradle │ │ ├── KlutterGradlePluginSpec.groovy │ │ ├── dsl │ │ ├── DependencyUtilsSpec.groovy │ │ ├── KlutterPluginDSLSpec.groovy │ │ └── KlutterVersionSpec.groovy │ │ └── tasks │ │ ├── CodeGenTasksSpec.groovy │ │ ├── CopyTasksSpec.groovy │ │ ├── GetKradleGradleTaskSpec.groovy │ │ ├── ProtoTasksSpec.groovy │ │ └── TaskTestUtil.groovy ├── jetbrains │ ├── .gitignore │ ├── CHANGELOG.md │ ├── build.gradle.kts │ ├── module.md │ └── src │ │ ├── main │ │ ├── kotlin │ │ │ └── dev │ │ │ │ └── buijs │ │ │ │ └── klutter │ │ │ │ └── jetbrains │ │ │ │ ├── JetbrainsExecutor.kt │ │ │ │ ├── KlutterMetadata.kt │ │ │ │ ├── NewProjectAction.kt │ │ │ │ ├── NewProjectBuilder.kt │ │ │ │ ├── NewProjectConfig.kt │ │ │ │ ├── NewProjectTaskFactory.kt │ │ │ │ └── NewProjectWizardStep.kt │ │ └── resources │ │ │ ├── META-INF │ │ │ ├── plugin.xml │ │ │ └── pluginIcon.svg │ │ │ ├── klutterBanner.svg │ │ │ ├── pluginIcon16x16.svg │ │ │ ├── pluginIcon20x20.svg │ │ │ └── pluginIcon512x512.png │ │ └── test │ │ └── kotlin │ │ └── dev │ │ └── buijs │ │ └── klutter │ │ └── jetbrains │ │ ├── shared │ │ ├── KlutterMetadataTest.kt │ │ └── NewProjectConfigValidatorTest.kt │ │ └── systemtest │ │ ├── SystemTest.kt │ │ ├── pages │ │ └── WelcomeFrame.kt │ │ └── utils │ │ ├── RemoteRobotExtension.kt │ │ └── StepsLogger.kt ├── kompose │ ├── build.gradle.kts │ ├── kompose.podspec │ ├── module.md │ └── src │ │ └── commonMain │ │ └── kotlin │ │ └── dev │ │ └── buijs │ │ └── klutter │ │ └── kompose │ │ ├── IosFlow.kt │ │ └── Publisher.kt └── kore │ ├── build.gradle.kts │ ├── module.md │ └── src │ ├── main │ ├── kotlin │ │ └── dev │ │ │ └── buijs │ │ │ └── klutter │ │ │ └── kore │ │ │ ├── Exception.kt │ │ │ ├── Interfaces.kt │ │ │ ├── ast │ │ │ ├── Controller.kt │ │ │ ├── FlutterChannel.kt │ │ │ ├── Implementations.kt │ │ │ ├── Method.kt │ │ │ ├── SquintTypes.kt │ │ │ ├── StandardTypeMap.kt │ │ │ ├── Type.kt │ │ │ └── TypeFactory.kt │ │ │ ├── common │ │ │ ├── Either.kt │ │ │ ├── ExcludeJacoco.kt │ │ │ ├── FileUtils.kt │ │ │ ├── JsonFormat.kt │ │ │ └── StringUtils.kt │ │ │ ├── project │ │ │ ├── Android.kt │ │ │ ├── Config.kt │ │ │ ├── Environment.kt │ │ │ ├── FlutterDistribution.kt │ │ │ ├── IOS.kt │ │ │ ├── Platform.kt │ │ │ ├── Project.kt │ │ │ ├── Properties.kt │ │ │ ├── Pubspec.kt │ │ │ ├── PubspecBuilder.kt │ │ │ └── Root.kt │ │ │ ├── tasks │ │ │ ├── CopyAarFileTask.kt │ │ │ ├── CopyXCFrameworkTask.kt │ │ │ ├── DownloadProtocTask.kt │ │ │ ├── Executor.kt │ │ │ ├── GetDartProtocExeTask.kt │ │ │ ├── GetKradleTask.kt │ │ │ ├── Zippie.kt │ │ │ ├── codegen │ │ │ │ ├── CompileProtoSchemaTask.kt │ │ │ │ ├── DartFormatTask.kt │ │ │ │ ├── ExcludeArm64Task.kt │ │ │ │ ├── GenerateAndroidLibTask.kt │ │ │ │ ├── GenerateCodeActions.kt │ │ │ │ ├── GenerateCodeOptions.kt │ │ │ │ ├── GenerateCodeTask.kt │ │ │ │ ├── GenerateFlutterControllersTask.kt │ │ │ │ ├── GenerateFlutterLibTask.kt │ │ │ │ ├── GenerateFlutterMessagesTask.kt │ │ │ │ ├── GenerateIosLibTask.kt │ │ │ │ ├── GenerateProtoExtensionsTask.kt │ │ │ │ ├── GenerateProtoSchemasTask.kt │ │ │ │ └── PubGetTask.kt │ │ │ └── project │ │ │ │ ├── ActionDownloadFlutter.kt │ │ │ │ ├── ActionDownloadProtoc.kt │ │ │ │ ├── ActionFlutterCreate.kt │ │ │ │ ├── ActionInitKlutter.kt │ │ │ │ ├── DownloadFlutterTask.kt │ │ │ │ ├── InputFlutterPath.kt │ │ │ │ ├── InputGroupName.kt │ │ │ │ ├── InputOrThrow.kt │ │ │ │ ├── InputPluginName.kt │ │ │ │ ├── InputRootFolder.kt │ │ │ │ ├── ProjectBuilderActions.kt │ │ │ │ ├── ProjectBuilderOptions.kt │ │ │ │ └── ProjectBuilderTask.kt │ │ │ └── templates │ │ │ ├── AndroidAdapter.kt │ │ │ ├── IosAdapter.kt │ │ │ ├── ProtobufExtensions.kt │ │ │ ├── Utilities.kt │ │ │ └── flutter │ │ │ ├── PackageLib.kt │ │ │ ├── PublisherWidget.kt │ │ │ ├── PubspecYaml.kt │ │ │ └── SubscriberWidget.kt │ └── resources │ │ └── protoc_plugin.exe │ └── test │ └── groovy │ └── dev │ └── buijs │ └── klutter │ └── kore │ ├── ExceptionSpec.groovy │ ├── ast │ ├── InterfacesSpec.groovy │ ├── StandardTypeMapSpec.groovy │ └── TypeFactorySpec.groovy │ ├── common │ ├── EitherSpec.groovy │ ├── FileUtilsSpec.groovy │ └── StringUtilsSpec.groovy │ ├── project │ ├── ConfigSpec.groovy │ ├── ProjectSpec.groovy │ └── PubspecSpec.groovy │ ├── tasks │ ├── CopyAarFileTaskSpec.groovy │ ├── CopyXCFrameworkTaskSpec.groovy │ ├── DummyExec.groovy │ ├── GetDartProtocExeTaskSpec.groovy │ ├── codegen │ │ ├── CompileProtoSchemaTaskSpec.groovy │ │ ├── DartFormatTaskSpec.groovy │ │ ├── ExcludeArm64TaskSpec.groovy │ │ └── GenerateProtoExtensionsTaskSpec.groovy │ └── project │ │ ├── ActionFlutterCreateSpec.groovy │ │ ├── ActionInitKlutterSpec.groovy │ │ ├── Exeggutor.groovy │ │ ├── GenerateCodeTaskSpec.groovy │ │ ├── InputGroupNameSpec.groovy │ │ ├── InputPluginNameSpec.groovy │ │ ├── InputRootFolderSpec.groovy │ │ ├── ProjectBuilderActionsSpec.groovy │ │ └── ProjectBuilderTaskSpec.groovy │ └── template │ ├── AndroidAdapterSpec.groovy │ ├── UtilitiesSpec.groovy │ └── flutter │ ├── PublisherWidgetSpec.groovy │ └── SubscriberWidgetSpec.groovy ├── settings.gradle.kts └── tools ├── .gitignore ├── build_publish_kore.compiler.gradle.sh ├── publish_all.sh ├── publish_annotations.sh ├── publish_bom.sh ├── publish_compiler.sh ├── publish_gradle_plugin.sh ├── publish_kompose.sh └── publish_kore.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [buijs-dev] -------------------------------------------------------------------------------- /.github/assets/metadata/icon/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/.github/assets/metadata/icon/banner.png -------------------------------------------------------------------------------- /.github/assets/metadata/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/.github/assets/metadata/icon/icon.png -------------------------------------------------------------------------------- /.github/assets/metadata/icon/klutter_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/.github/assets/metadata/icon/klutter_logo.png -------------------------------------------------------------------------------- /.github/assets/metadata/icon/klutter_logo_animated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/.github/assets/metadata/icon/klutter_logo_animated.gif -------------------------------------------------------------------------------- /.github/assets/metadata/icon/klutter_logo_animated2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/.github/assets/metadata/icon/klutter_logo_animated2.gif -------------------------------------------------------------------------------- /.github/assets/metadata/icon/klutter_logo_animated3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/.github/assets/metadata/icon/klutter_logo_animated3.gif -------------------------------------------------------------------------------- /.github/assets/metadata/icon/logo_animated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/.github/assets/metadata/icon/logo_animated.gif -------------------------------------------------------------------------------- /.github/badges/ccvbadge.svgnotusedatm: -------------------------------------------------------------------------------- 1 | coverage: 80coverage80 -------------------------------------------------------------------------------- /.github/badges/license.svg: -------------------------------------------------------------------------------- 1 | license: MITlicenseMIT -------------------------------------------------------------------------------- /.github/workflows/codecov.yml: -------------------------------------------------------------------------------- 1 | name: Publish to Codecov 2 | 3 | on: 4 | push: 5 | env: 6 | KLUTTER_PRIVATE_USERNAME: ${{ secrets.KLUTTER_PRIVATE_USERNAME }} 7 | KLUTTER_PRIVATE_PASSWORD: ${{ secrets.KLUTTER_PRIVATE_PASSWORD }} 8 | KLUTTER_PRIVATE_URL: ${{ secrets.KLUTTER_PRIVATE_URL }} 9 | KLUTTER_JETBRAINS_CERTIFICATE_CHAINS: ${{ secrets.KLUTTER_JETBRAINS_CERTIFICATE_CHAINS }} 10 | KLUTTER_JETBRAINS_PRIVATE_KEY: ${{ secrets.KLUTTER_JETBRAINS_PRIVATE_KEY }} 11 | KLUTTER_JETBRAINS_PRIVATE_KEY_PASSWORD: ${{ secrets.KLUTTER_JETBRAINS_PRIVATE_KEY_PASSWORD }} 12 | 13 | jobs: 14 | gradle: 15 | strategy: 16 | matrix: 17 | os: [ macos-latest ] 18 | runs-on: ${{ matrix.os }} 19 | timeout-minutes: 60 20 | steps: 21 | - uses: actions/checkout@v4 22 | with: 23 | fetch-depth: 0 24 | - uses: actions/setup-java@v4 25 | with: 26 | distribution: 'adopt' 27 | java-version: 17 28 | cache: gradle 29 | - uses: subosito/flutter-action@v2 30 | with: 31 | flutter-version: '3.0.5' 32 | channel: 'stable' 33 | - uses: gradle/actions/setup-gradle@v3 34 | with: 35 | gradle-version: 8.3 36 | arguments: clean build koverMergedXmlReport -p "lib" 37 | 38 | - uses: codecov/codecov-action@v2 39 | with: 40 | file: lib/build/koverage.xml 41 | env: 42 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/dokka.yml: -------------------------------------------------------------------------------- 1 | name: Publish Dokka to Github Pages 2 | 3 | on: 4 | push: 5 | env: 6 | KLUTTER_PRIVATE_USERNAME: ${{ secrets.KLUTTER_PRIVATE_USERNAME }} 7 | KLUTTER_PRIVATE_PASSWORD: ${{ secrets.KLUTTER_PRIVATE_PASSWORD }} 8 | KLUTTER_PRIVATE_URL: ${{ secrets.KLUTTER_PRIVATE_URL }} 9 | KLUTTER_JETBRAINS_CERTIFICATE_CHAINS: ${{ secrets.KLUTTER_JETBRAINS_CERTIFICATE_CHAINS }} 10 | KLUTTER_JETBRAINS_PRIVATE_KEY: ${{ secrets.KLUTTER_JETBRAINS_PRIVATE_KEY }} 11 | KLUTTER_JETBRAINS_PRIVATE_KEY_PASSWORD: ${{ secrets.KLUTTER_JETBRAINS_PRIVATE_KEY_PASSWORD }} 12 | 13 | jobs: 14 | gradle: 15 | strategy: 16 | matrix: 17 | os: [ macos-latest ] 18 | runs-on: ${{ matrix.os }} 19 | timeout-minutes: 60 20 | steps: 21 | - name: 'checkout source' 22 | uses: actions/checkout@v4 23 | - name: 'setup java' 24 | uses: actions/setup-java@v4 25 | with: 26 | distribution: 'adopt' 27 | java-version: 17 28 | - name: 'setup gradle' 29 | uses: gradle/actions/setup-gradle@v3 30 | with: 31 | gradle-version: 8.3 32 | - name: 'setup flutter' 33 | uses: subosito/flutter-action@v2 34 | with: 35 | flutter-version: '3.0.5' 36 | channel: 'stable' 37 | - name: 'create docs' 38 | run: gradle dokkaHtmlMultiModule -p "lib" 39 | - name: 'upload to github pages' 40 | uses: crazy-max/ghaction-github-pages@v2 41 | with: 42 | target_branch: gh-pages 43 | build_dir: lib/build/dokkaSite 44 | env: 45 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 - 2024 Buijs Software 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | SOFTWARE. 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://img.shields.io/badge/Buijs-Software-blue)](https://pub.dev/publishers/buijs.dev/packages) 2 | [![Jetbrains Marketplace](https://img.shields.io/jetbrains/plugin/v/19846-klutter?label=Jetbrains%20Plugin)](https://plugins.jetbrains.com/plugin/19846-klutter) 3 | [![CodeScene Code Health](https://codescene.io/projects/27235/status-badges/code-health)](https://codescene.io/projects/27235) 4 | [![codecov](https://codecov.io/gh/buijs-dev/klutter/branch/main/graph/badge.svg)](https://codecov.io/gh/buijs-dev/klutter) 5 | [![GitHub](https://img.shields.io/github/license/buijs-dev/klutter?color=black)](https://github.com/buijs-dev/klutter/blob/main/LICENSE) 6 | buijs software logo 7 | 8 | Klutter is a framework which interconnects Flutter and Kotlin Multiplatform. 9 | It can be used to create Flutter plugins. 10 | 11 | ### Getting started 12 | - Start a new project with the 13 | - [Intellij](https://buijs.dev/klutter-3/) plugin 14 | - [Android Studio](https://buijs.dev/klutter-4/) plugin 15 | - [Kradle](https://buijs.dev/kradle-1/) cli tool 16 | - For recipes see the [cookbook](https://github.com/buijs-dev/klutter-cookbook) 17 | 18 | ### Framework 19 | - [Annotations](lib/annotations/module.md) 20 | - [Kore](lib/kore/module.md) 21 | - [Plugin: Gradle](lib/gradle/module.md) 22 | - [Plugin: Flutter](https://github.com/buijs-dev/klutter-dart) 23 | - [Plugin: Jetbrains (Intellij, Android Studio)](lib/jetbrains/module.md) 24 | 25 | ### Documentation 26 | - [KDoc](https://buijs-dev.github.io/klutter/) -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "1.9.10" 3 | } 4 | 5 | buildscript { 6 | 7 | repositories { 8 | google() 9 | gradlePluginPortal() 10 | mavenCentral() 11 | mavenLocal() 12 | } 13 | 14 | dependencies { 15 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10") 16 | classpath("com.android.tools.build:gradle:8.1.4") 17 | } 18 | } 19 | 20 | allprojects { 21 | repositories { 22 | google() 23 | gradlePluginPortal() 24 | mavenCentral() 25 | maven { url = uri("https://jitpack.io") } // KInquirer 26 | } 27 | } -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | github_checks: 2 | annotations: false 3 | 4 | ignore: 5 | # These classes contain glue code for which code coverage is not recorded 6 | - lib/klutter-gradle/src/main/kotlin/dev/buijs/klutter/gradle 7 | # Mostly tested through UI (e2e) tests for which coverage is not recorded 8 | - lib/klutter-jetbrains/src/main/kotlin/dev/buijs/klutter/jetbrains 9 | # Integration test tooling 10 | - lib/klutter-test/src/main/kotlin/dev/buijs/klutter/test -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xms3096M -Xmx8192M -Dkotlin.daemon.jvm.options\="-Xmx8192M" 2 | kotlin.mpp.stability.nowarn=true 3 | kotlin.mpp.enableCInteropCommonization=true 4 | kotlin.native.cacheKind.iosArm64=none 5 | kotlin.stdlib.default.dependency = false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /lib-build/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "1.9.10" 3 | id("java-gradle-plugin") 4 | } 5 | 6 | kotlin { 7 | jvmToolchain { 8 | languageVersion.set(JavaLanguageVersion.of(17)) 9 | } 10 | } 11 | 12 | gradlePlugin { 13 | plugins.register("klutter") { 14 | id = "klutter" 15 | implementationClass = "dev.buijs.klutter.KlutterInternalPlugin" 16 | } 17 | } 18 | 19 | buildscript { 20 | repositories { 21 | google() 22 | gradlePluginPortal() 23 | mavenCentral() 24 | } 25 | 26 | dependencies { 27 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10") 28 | } 29 | } 30 | 31 | allprojects { 32 | repositories { 33 | google() 34 | gradlePluginPortal() 35 | mavenCentral() 36 | } 37 | } 38 | 39 | dependencies { 40 | implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10") 41 | implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.4.0") 42 | implementation(gradleApi()) 43 | } -------------------------------------------------------------------------------- /lib-build/src/main/resources/publish.properties: -------------------------------------------------------------------------------- 1 | annotations.version=2024.1.3.beta 2 | bom.version=2024.1.3.beta 3 | compiler.version=2024.1.3.beta 4 | flutter.engine.version=2024.1.3.beta 5 | kompose.version=2024.1.3.beta 6 | kore.version=2024.1.3.beta 7 | plugin.gradle.version=2024.1.3.beta 8 | plugin.jetbrains.version=2024.1.3.beta -------------------------------------------------------------------------------- /lib-build/src/main/resources/repository.properties: -------------------------------------------------------------------------------- 1 | repo.username=none 2 | repo.password=none 3 | repo.endpoint=none -------------------------------------------------------------------------------- /lib-test/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | id("klutter") 4 | id("groovy") 5 | id("java-library") 6 | } 7 | 8 | java { 9 | withJavadocJar() 10 | withSourcesJar() 11 | sourceCompatibility = JavaVersion.VERSION_17 12 | targetCompatibility = JavaVersion.VERSION_17 13 | } 14 | 15 | kotlin { 16 | jvmToolchain { 17 | languageVersion.set(JavaLanguageVersion.of(17)) 18 | } 19 | } 20 | 21 | sourceSets { 22 | main { 23 | java { 24 | srcDirs("${projectDir.absolutePath}/src/main/kotlin") 25 | } 26 | } 27 | 28 | test { 29 | java { 30 | srcDirs("${projectDir.absolutePath}/src/test/kotlin") 31 | } 32 | } 33 | } 34 | 35 | dependencies { 36 | //Kotlin 37 | implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.22") 38 | implementation("org.jetbrains.kotlin:kotlin-compiler:1.7.10") 39 | 40 | //Jackson for XML 41 | implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1") 42 | implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.16.1") 43 | implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.1") 44 | 45 | //Logging 46 | implementation("org.slf4j:slf4j-api:2.0.7") 47 | implementation("io.github.microutils:kotlin-logging:3.0.5") 48 | 49 | // Gradle 50 | api(gradleApi()) 51 | api(gradleTestKit()) 52 | 53 | // Spock 54 | api("org.codehaus.groovy:groovy-all:3.0.17") 55 | api("org.spockframework:spock-core:2.2-M1-groovy-3.0") 56 | 57 | // Mockingjay 58 | api("org.mockito:mockito-core:4.6.1") 59 | api("org.mockito.kotlin:mockito-kotlin:4.0.0") 60 | 61 | // Kotlin Test 62 | @Suppress("GradleDependency") // 30-07-2022 newest 3.4.2 throws exceptions 63 | api("io.kotlintest:kotlintest-runner-junit5:3.3.0") 64 | } 65 | 66 | tasks.named("test") { 67 | useJUnitPlatform() 68 | } -------------------------------------------------------------------------------- /lib-test/module.md: -------------------------------------------------------------------------------- 1 | # Module klutter-test 2 | 3 | Testing library. -------------------------------------------------------------------------------- /lib-test/src/main/kotlin/dev/buijs/klutter/kore/test/TestException.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | 23 | package dev.buijs.klutter.kore.test 24 | 25 | /** 26 | * Exception which indicates a problem configuring or executing a test. 27 | * 28 | * @author Gillian Buijs 29 | */ 30 | class TestException(msg: String): Exception(msg) -------------------------------------------------------------------------------- /lib-test/src/main/resources/android_adapter: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.adapter 2 | 3 | import foo.bar.baz.FakeClass 4 | import io.flutter.plugin.common.MethodChannel 5 | import io.flutter.plugin.common.MethodCall 6 | import kotlinx.coroutines.CoroutineScope 7 | import kotlinx.coroutines.Dispatchers 8 | import kotlinx.coroutines.launch 9 | 10 | /** 11 | * Generated code by the Klutter Framework 12 | */ 13 | class GeneratedKlutterAdapter { 14 | 15 | private val mainScope = CoroutineScope(Dispatchers.Main) 16 | 17 | fun handleMethodCalls(call: MethodCall, result: MethodChannel.Result) { 18 | mainScope.launch { 19 | when (call.method) { 20 | "DartMaul" -> { 21 | result.success(FakeClass().foo()) 22 | } 23 | "BabyYoda" -> { 24 | result.success(FakeClass().fooBar().toKJson()) 25 | } 26 | "ObiWan" -> { 27 | result.success(FakeClass().zeta().toKJson()) 28 | } 29 | else -> result.notImplemented() 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /lib-test/src/main/resources/android_app_manifest: -------------------------------------------------------------------------------- 1 | 3 | 6 | 14 | 18 | 22 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 41 | 42 | -------------------------------------------------------------------------------- /lib-test/src/main/resources/android_main_activity: -------------------------------------------------------------------------------- 1 | package foo.bar.baz.appz 2 | 3 | import dev.buijs.klutter.adapter.GeneratedKlutterAdapter 4 | import io.flutter.plugin.common.MethodChannel 5 | import io.flutter.embedding.android.FlutterActivity 6 | import androidx.annotation.NonNull 7 | import io.flutter.embedding.engine.FlutterEngine 8 | 9 | class MainActivity: FlutterActivity() { 10 | 11 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 12 | MethodChannel(flutterEngine.dartExecutor,"KLUTTER") 13 | .setMethodCallHandler{ call, result -> 14 | GeneratedKlutterAdapter().handleMethodCalls(call, result) 15 | } 16 | GeneratedPluginRegistrant.registerWith(flutterEngine) 17 | } 18 | } -------------------------------------------------------------------------------- /lib-test/src/main/resources/build_gradle_plugin: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("dev.buijs.klutter") 3 | } 4 | 5 | klutter { 6 | root = rootProject.rootDir 7 | plugin { } 8 | } -------------------------------------------------------------------------------- /lib-test/src/main/resources/ios_swift_plugin: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import Platform 4 | 5 | public class SwiftSuperAwesomePlugin: NSObject, FlutterPlugin { 6 | public static func register(with registrar: FlutterPluginRegistrar) { 7 | let channel = FlutterMethodChannel(name: "foo.bar.super_awesome", binaryMessenger: registrar.messenger()) 8 | let instance = SwiftSuperAwesomePlugin() 9 | registrar.addMethodCallDelegate(instance, channel: channel) 10 | } 11 | 12 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 13 | switch call.method { 14 | case "DartMaul": 15 | self.DartMaul(result: result) 16 | case "BabyYoda": 17 | self.BabyYoda(result: result) 18 | case "ObiWan": 19 | self.ObiWan(result: result) 20 | default: 21 | result(FlutterMethodNotImplemented) 22 | } 23 | } 24 | 25 | func DartMaul(result: @escaping FlutterResult) { 26 | result(FakeClass().foo()) 27 | } 28 | 29 | func BabyYoda(result: @escaping FlutterResult) { 30 | result(FakeClass().fooBar().toKJson()) 31 | } 32 | 33 | func ObiWan(result: @escaping FlutterResult) { 34 | FakeClass().zeta { data, error in 35 | if let response = data { result(response.toKJson()) } 36 | 37 | if let failure = error { result(failure) } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib-test/src/main/resources/klutter_android_main_activity: -------------------------------------------------------------------------------- 1 | package foo.bar.baz.appz 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | import androidx.annotation.NonNull 5 | import io.flutter.embedding.engine.FlutterEngine 6 | 7 | class MainActivity: FlutterActivity() { 8 | 9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 10 | GeneratedPluginRegistrant.registerWith(flutterEngine) 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /lib-test/src/main/resources/kompose_build_gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | id("dev.buijs.klutter") 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | maven { 9 | url = uri("https://repsy.io/mvn/buijs-dev/klutter-private") 10 | credentials { 11 | username = "buijs-dev" 12 | password = "LoginRepsy89!" 13 | } 14 | } 15 | } 16 | 17 | sourceSets { 18 | main { 19 | java { 20 | srcDirs("${projectDir.absolutePath}/src") 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation("dev.buijs.klutter:kompose:0.14.1") 27 | implementation("dev.buijs.klutter:core:0.14.1") 28 | implementation("dev.buijs.klutter:annotations-jvm:0.14.1") 29 | } 30 | 31 | java { 32 | sourceCompatibility = JavaVersion.VERSION_11 33 | targetCompatibility = JavaVersion.VERSION_11 34 | } 35 | 36 | tasks.named("test") { 37 | useJUnitPlatform() 38 | } -------------------------------------------------------------------------------- /lib-test/src/main/resources/kompose_feed: -------------------------------------------------------------------------------- 1 | import dev.buijs.klutter.annotations.jvm.KomposeView 2 | import dev.buijs.klutter.dev.buijs.klutter.ui.* 3 | import dev.buijs.klutter.dev.buijs.klutter.ui.builder.KlutterScreen 4 | import dev.buijs.klutter.dev.buijs.klutter.ui.builder.KlutterUI 5 | import dev.buijs.klutter.dev.buijs.klutter.ui.viewmodel.Navigator 6 | 7 | @KomposeView 8 | class Feed: KlutterUI(name = "Feed") { 9 | 10 | override fun screen(): KlutterScreen = { 11 | SafeArea { 12 | Scaffold { 13 | Center { 14 | Column { 15 | children( 16 | Text("Feed"), 17 | TextButton( 18 | model = Navigator(), 19 | text = "Go to home", 20 | ) { 21 | route = "home" 22 | arguments = "Data from feed" 23 | }, 24 | ) 25 | } 26 | } 27 | } 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib-test/src/main/resources/kompose_home: -------------------------------------------------------------------------------- 1 | import dev.buijs.klutter.annotations.jvm.KomposeView 2 | import dev.buijs.klutter.dev.buijs.klutter.ui.* 3 | import dev.buijs.klutter.dev.buijs.klutter.ui.builder.JetlagScreen 4 | import dev.buijs.klutter.dev.buijs.klutter.ui.builder.JetlagUI 5 | import dev.buijs.klutter.dev.buijs.klutter.ui.viewmodel.Navigator 6 | 7 | @KomposeView 8 | class Home: JetlagUI(name = "Home") { 9 | 10 | override fun screen(): JetlagScreen = { 11 | SafeArea { 12 | Scaffold { 13 | Center { 14 | Column { 15 | children( 16 | Text("Home"), 17 | TextButton( 18 | model = Navigator(), 19 | text = "Go to feed", 20 | ) { 21 | route = "feed" 22 | arguments = "Data from home" 23 | }, 24 | ) 25 | } 26 | } 27 | } 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib-test/src/main/resources/kompose_root_build_gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | maven { url = uri("https://repsy.io/mvn/buijs-dev/klutter") } 7 | } 8 | dependencies { 9 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10") 10 | classpath("com.android.tools.build:gradle:7.2.1") 11 | classpath("dev.buijs.klutter:core:0.14.1") 12 | classpath("dev.buijs.klutter.gradle:dev.buijs.klutter.gradle.gradle.plugin:0.14.2") 13 | } 14 | } 15 | 16 | repositories { 17 | google() 18 | gradlePluginPortal() 19 | mavenCentral() 20 | maven { url = uri("https://repsy.io/mvn/buijs-dev/klutter") } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | google() 26 | gradlePluginPortal() 27 | mavenCentral() 28 | maven { 29 | url = uri("https://repsy.io/mvn/buijs-dev/klutter") 30 | } 31 | } 32 | 33 | } 34 | 35 | tasks.register("klutterInstallFrontend", Exec::class) { 36 | commandLine("bash", "./gradlew", "clean", "build","-p", "kompose") 37 | finalizedBy("klutterKomposeGenerateUI") 38 | } 39 | 40 | tasks.register("klutterKomposeGenerateUI", Exec::class) { 41 | commandLine("bash", "./gradlew", "klutterGenerateUI", "-p", "kompose") 42 | } -------------------------------------------------------------------------------- /lib-test/src/main/resources/kompose_settings_gradle: -------------------------------------------------------------------------------- 1 | include(":kompose") -------------------------------------------------------------------------------- /lib-test/src/main/resources/platform_source_code: -------------------------------------------------------------------------------- 1 | package foo.bar.baz 2 | 3 | import dev.buijs.klutter.annotations.Annotations 4 | 5 | class FakeClass { 6 | @Event(name = "DartMaul") 7 | fun foo(): String { 8 | return "Maul" 9 | } 10 | 11 | @Event(name = "BabyYoda") 12 | fun fooBar(): List { 13 | return listOf("baz") 14 | } 15 | 16 | @Event(name = "ObiWan") 17 | suspend fun zeta(): List = 18 | listOf(foo()).map { str -> 19 | "str = str " 20 | }.filter { baz -> 21 | baz != "" 22 | } 23 | 24 | } 25 | 26 | @Serializable 27 | @Response 28 | enum class { 29 | @SerialName("boom") BOOM, 30 | @SerialName("boom boom") BOOM_BOOM, 31 | } -------------------------------------------------------------------------------- /lib-test/src/main/resources/plugin_ios_podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint impressive_dependency.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'impressive_dependency' 7 | s.version = '0.0.1' 8 | s.summary = 'A new flutter plugin project.' 9 | s.description = <<-DESC 10 | A new flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | 19 | s.ios.vendored_frameworks = "Klutter/Platform.framework" 20 | 21 | s.platform = :ios, '9.0' 22 | 23 | # Flutter.framework does not contain a i386 slice. 24 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } 25 | 26 | s.swift_version = '5.0' 27 | end 28 | -------------------------------------------------------------------------------- /lib-test/src/main/resources/plugin_ios_podspec_excluded: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint impressive_dependency.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'impressive_dependency' 7 | s.version = '0.0.1' 8 | s.summary = 'A new flutter plugin project.' 9 | s.description = <<-DESC 10 | A new flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } 19 | s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } 20 | 21 | s.ios.vendored_frameworks = "Klutter/Platform.framework" 22 | 23 | s.platform = :ios, '9.0' 24 | 25 | # Flutter.framework does not contain a i386 slice. 26 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } 27 | 28 | s.swift_version = '5.0' 29 | end -------------------------------------------------------------------------------- /lib-test/src/main/resources/plugin_platform_podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'ridiculous_plugin' 3 | spec.version = '1.0' 4 | spec.homepage = 'Link to the Shared Module homepage' 5 | spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" } 6 | spec.authors = '' 7 | spec.license = '' 8 | spec.summary = 'Some description for the Shared Module' 9 | 10 | spec.vendored_frameworks = "build/cocoapods/framework/Platform.xcframework" 11 | spec.libraries = "c++" 12 | spec.module_name = "#{spec.name}_umbrella" 13 | 14 | spec.ios.deployment_target = '14.1' 15 | 16 | spec.pod_target_xcconfig = { 17 | 'KOTLIN_PROJECT_PATH' => ':klutter:ridiculous_plugin', 18 | 'PRODUCT_MODULE_NAME' => 'ridiculous_plugin', 19 | } 20 | 21 | spec.script_phases = [ 22 | { 23 | :name => 'Build ridiculous_plugin', 24 | :execution_position => :before_compile, 25 | :shell_path => '/bin/sh', 26 | :script => <<-SCRIPT 27 | if [ "YES" = "$COCOAPODS_SKIP_KOTLIN_BUILD" ]; then 28 | echo "Skipping Gradle build task invocation due to COCOAPODS_SKIP_KOTLIN_BUILD environment variable set to \"YES\"" 29 | exit 0 30 | fi 31 | set -ev 32 | REPO_ROOT="$PODS_TARGET_SRCROOT" 33 | "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ 34 | -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ 35 | -Pkotlin.native.cocoapods.archs="$ARCHS" \ 36 | -Pkotlin.native.cocoapods.configuration=$CONFIGURATION 37 | SCRIPT 38 | } 39 | ] 40 | end -------------------------------------------------------------------------------- /lib-test/src/main/resources/plugin_pubspec: -------------------------------------------------------------------------------- 1 | name: super_awesome 2 | description: A new flutter plugin project. 3 | version: 0.0.1 4 | homepage: 5 | 6 | environment: 7 | sdk: ">=2.16.1 <3.0.0" 8 | flutter: ">=2.5.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | flutter_lints: ^1.0.0 18 | 19 | klutter: 20 | path: ../../../klutter-dart 21 | 22 | # For information on the generic Dart part of this file, see the 23 | # following page: https://dart.dev/tools/pub/pubspec 24 | 25 | # The following section is specific to Flutter. 26 | flutter: 27 | plugin: 28 | platforms: 29 | android: 30 | package: foo.bar.super_awesome 31 | pluginClass: SuperAwesomePlugin 32 | ios: 33 | pluginClass: SuperAwesomePlugin 34 | -------------------------------------------------------------------------------- /lib-test/src/main/resources/settings_gradle_plugin: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 - 2022 Buijs Software 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | include(":klutter:super_awesome") 21 | project(":klutter:super_awesome").projectDir = File("platform") 22 | include(":android") -------------------------------------------------------------------------------- /lib-test/src/test/groovy/dev/buijs/klutter/kore/test/TestResourceSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | 23 | package dev.buijs.klutter.kore.test 24 | 25 | import spock.lang.Specification 26 | 27 | import java.nio.file.Files 28 | 29 | /** 30 | * @author Gillian Buijs 31 | */ 32 | class TestResourceSpec extends Specification { 33 | 34 | def "Verify a resource is loaded as String" (){ 35 | 36 | given: 37 | def resources = new TestResource() 38 | 39 | when: 40 | def content = resources.load("android_adapter") 41 | 42 | then: 43 | content != null 44 | content != "" 45 | 46 | } 47 | 48 | def "Verify a resource is copied" (){ 49 | 50 | given: 51 | def resources = new TestResource() 52 | def target = Files.createTempDirectory("") 53 | def actual = new File("${target.toFile().absolutePath}/foo.kt") 54 | 55 | when: 56 | resources.copy("android_adapter", actual) 57 | 58 | then: 59 | actual != null 60 | actual.exists() 61 | actual.text != null 62 | actual.text != "" 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /lib/annotations/annotations.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'annotations' 3 | spec.version = '2024.1.3.beta' 4 | spec.homepage = 'https://buijs.dev' 5 | spec.source = { :http=> ''} 6 | spec.authors = '' 7 | spec.license = '' 8 | spec.summary = 'Klutter module for annotations' 9 | spec.vendored_frameworks = 'build/cocoapods/framework/Annotations.framework' 10 | spec.libraries = 'c++' 11 | spec.ios.deployment_target = '9.0' 12 | 13 | 14 | spec.pod_target_xcconfig = { 15 | 'KOTLIN_PROJECT_PATH' => ':lib:annotations', 16 | 'PRODUCT_MODULE_NAME' => 'Annotations', 17 | } 18 | 19 | spec.script_phases = [ 20 | { 21 | :name => 'Build annotations', 22 | :execution_position => :before_compile, 23 | :shell_path => '/bin/sh', 24 | :script => <<-SCRIPT 25 | if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then 26 | echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" 27 | exit 0 28 | fi 29 | set -ev 30 | REPO_ROOT="$PODS_TARGET_SRCROOT" 31 | "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ 32 | -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ 33 | -Pkotlin.native.cocoapods.archs="$ARCHS" \ 34 | -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" 35 | SCRIPT 36 | } 37 | ] 38 | 39 | end -------------------------------------------------------------------------------- /lib/annotations/src/androidMain/kotlin/dev/buijs/klutter/annotations/KlutterAnnotations.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("unused") 2 | /* Copyright (c) 2021 - 2022 Buijs Software 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | * 22 | */ 23 | package dev.buijs.klutter.annotations 24 | 25 | @Retention(AnnotationRetention.SOURCE) 26 | @Target(AnnotationTarget.FUNCTION) 27 | actual annotation class Event( 28 | actual val name: String, 29 | ) 30 | 31 | @Retention(AnnotationRetention.SOURCE) 32 | @Target(AnnotationTarget.CLASS) 33 | actual annotation class Response() 34 | 35 | @Retention(AnnotationRetention.SOURCE) 36 | @Target(AnnotationTarget.FUNCTION) 37 | actual annotation class AndroidContext() 38 | 39 | @Retention(AnnotationRetention.SOURCE) 40 | @Target(AnnotationTarget.CLASS) 41 | actual annotation class Controller( 42 | actual val type: ControllerType 43 | ) 44 | -------------------------------------------------------------------------------- /lib/annotations/src/iosMain/kotlin/dev/buijs/klutter/annotations/KlutterAnnotations.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("unused") 2 | /* Copyright (c) 2021 - 2022 Buijs Software 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | * 22 | */ 23 | package dev.buijs.klutter.annotations 24 | 25 | @Retention(AnnotationRetention.SOURCE) 26 | @Target(AnnotationTarget.FUNCTION) 27 | actual annotation class Event( 28 | actual val name: String, 29 | ) 30 | 31 | @Retention(AnnotationRetention.SOURCE) 32 | @Target(AnnotationTarget.CLASS) 33 | actual annotation class Response() 34 | 35 | @Retention(AnnotationRetention.SOURCE) 36 | @Target(AnnotationTarget.FUNCTION) 37 | actual annotation class AndroidContext() 38 | 39 | /** 40 | * Annotation which informs Klutter to implement multiple 41 | * method channel calls to pass KlutterEvents to this Controller class. 42 | * 43 | * Should be used in conjunction with KomposeController super class. 44 | */ 45 | @Retention(AnnotationRetention.SOURCE) 46 | @Target(AnnotationTarget.CLASS) 47 | actual annotation class Controller( 48 | actual val type: ControllerType 49 | ) -------------------------------------------------------------------------------- /lib/annotations/src/jvmMain/kotlin/dev/buijs/klutter/annotations/KlutterAnnotations.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("unused") 2 | /* Copyright (c) 2021 - 2022 Buijs Software 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | * 22 | */ 23 | package dev.buijs.klutter.annotations 24 | 25 | @Retention(AnnotationRetention.SOURCE) 26 | @Target(AnnotationTarget.FUNCTION) 27 | actual annotation class Event( 28 | actual val name: String, 29 | ) 30 | 31 | @Retention(AnnotationRetention.SOURCE) 32 | @Target(AnnotationTarget.CLASS) 33 | actual annotation class Response() 34 | 35 | @Retention(AnnotationRetention.SOURCE) 36 | @Target(AnnotationTarget.FUNCTION) 37 | actual annotation class AndroidContext() 38 | 39 | @Retention(AnnotationRetention.SOURCE) 40 | @Target(AnnotationTarget.CLASS) 41 | actual annotation class Controller( 42 | actual val type: ControllerType 43 | ) -------------------------------------------------------------------------------- /lib/bill-of-materials/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-platform") 3 | id("maven-publish") 4 | id("klutter") 5 | } 6 | 7 | group = "dev.buijs.klutter" 8 | version = dev.buijs.klutter.ProjectVersions.bom 9 | 10 | publishing { 11 | 12 | repositories { 13 | maven { 14 | url = dev.buijs.klutter.Repository.endpoint 15 | credentials { 16 | username = dev.buijs.klutter.Repository.username 17 | password = dev.buijs.klutter.Repository.password 18 | } 19 | } 20 | } 21 | 22 | publications { 23 | create("maven") { 24 | groupId = "dev.buijs.klutter" 25 | artifactId = "bom" 26 | version = dev.buijs.klutter.ProjectVersions.bom 27 | afterEvaluate { from(components["javaPlatform"]) } 28 | pom { 29 | name.set("Klutter: Bill of Materials") 30 | description.set("Collection of compatible Klutter dependencies.") 31 | url.set("https://buijs.dev/klutter/") 32 | 33 | licenses { 34 | license { 35 | name.set("MIT License") 36 | url.set("https://github.com/buijs-dev/klutter/blob/main/LICENSE") 37 | } 38 | } 39 | 40 | developers { 41 | developer { 42 | id.set("buijs-dev") 43 | name.set("Gillian Buijs") 44 | email.set("info@buijs.dev") 45 | } 46 | } 47 | 48 | scm { 49 | connection.set("git@github.com:buijs-dev/klutter.git") 50 | developerConnection.set("git@github.com:buijs-dev/klutter.git") 51 | url.set("https://github.com/buijs-dev/klutter") 52 | } 53 | 54 | } 55 | } 56 | } 57 | } 58 | 59 | // List of modules to include in the bom artifact. 60 | val includeModules = listOf( 61 | "annotations", 62 | "compiler", 63 | "gradle", 64 | "kompose", 65 | "kore", 66 | "tasks" 67 | ) 68 | dependencies { 69 | constraints { 70 | project.rootProject.subprojects.forEach { subproject -> 71 | if (subproject.name in includeModules) { 72 | api(subproject) 73 | } 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /lib/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.dokka.gradle.DokkaTask 2 | 3 | plugins { 4 | kotlin("jvm") 5 | id("org.jetbrains.dokka") version "1.9.20" 6 | id("org.jetbrains.kotlinx.kover") version "0.5.1" 7 | id("klutter") 8 | } 9 | 10 | subprojects { 11 | plugins.apply("org.jetbrains.dokka") 12 | } 13 | 14 | kotlin { 15 | jvmToolchain { 16 | languageVersion.set(JavaLanguageVersion.of(17)) 17 | } 18 | } 19 | 20 | kover { 21 | 22 | // KOVER destroys running with coverage from IDE 23 | isDisabled = hasProperty("nokover") 24 | 25 | coverageEngine.set(kotlinx.kover.api.CoverageEngine.JACOCO) 26 | 27 | jacocoEngineVersion.set("0.8.8") 28 | 29 | disabledProjects = setOf( 30 | // contains only annotations 31 | // and breaks Jacoco due to duplicate classes 32 | ":lib:annotations", 33 | 34 | // breaks Jacoco due to duplicate classes, haven't found a fix yet... 35 | ":lib:kompose", 36 | 37 | // ST can't be run remote (yet)... 38 | ":lib:jetbrains", 39 | 40 | // a test-only module 41 | ":lib-test", 42 | ) 43 | } 44 | 45 | tasks.withType().configureEach { 46 | dokkaSourceSets { 47 | configureEach { 48 | includeNonPublic 49 | } 50 | } 51 | } 52 | 53 | tasks.dokkaHtmlMultiModule.configure { 54 | outputDirectory.set(layout.buildDirectory.dir("dokkaSite")) 55 | } 56 | 57 | tasks.koverMergedXmlReport { 58 | isEnabled = true 59 | 60 | excludes = listOf( 61 | // A test-only module 62 | "dev.buijs.klutter.kore.test.*", 63 | "dev.buijs.klutter.kore.common.ExcludeJacoco.kt") 64 | 65 | xmlReportFile.set(layout.buildDirectory.file("koverage.xml")) 66 | } -------------------------------------------------------------------------------- /lib/compiler/module.md: -------------------------------------------------------------------------------- 1 | # Klutter Compiler 2 | 3 | This module contains the Klutter compiler plugin. -------------------------------------------------------------------------------- /lib/compiler/src/main/kotlin/dev/buijs/klutter/compiler/processor/ProcessorProvider.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.compiler.processor 23 | 24 | import com.google.devtools.ksp.processing.SymbolProcessorEnvironment 25 | import com.google.devtools.ksp.processing.SymbolProcessorProvider 26 | import dev.buijs.klutter.kore.KlutterException 27 | 28 | /** 29 | * The provider which will return an instance of [Processor]. 30 | * 31 | * The build.gradle(.kts) of the workload module should contain 32 | * a ksp DSL block with the following option: 33 | * - key: klutterScanFolder, 34 | * - value: path to folder where scan result is stored. 35 | * 36 | * If the klutterScanFolder is not set then a [KlutterException] is thrown. 37 | * If the folder does not exist then a [KlutterException] is thrown. 38 | * See [ProcessorOptions] for all available configuration options. 39 | */ 40 | class ProcessorProvider : SymbolProcessorProvider { 41 | override fun create(environment: SymbolProcessorEnvironment) = 42 | Processor(env = environment, log = environment.logger) 43 | } -------------------------------------------------------------------------------- /lib/compiler/src/main/kotlin/dev/buijs/klutter/compiler/scanner/ControllerOutput.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.compiler.scanner 23 | 24 | import dev.buijs.klutter.kore.ast.Controller 25 | import dev.buijs.klutter.kore.common.EitherNok 26 | import dev.buijs.klutter.kore.common.EitherOk 27 | import dev.buijs.klutter.kore.common.maybeCreate 28 | import dev.buijs.klutter.kore.common.maybeCreateFolder 29 | import java.io.File 30 | 31 | /** 32 | * Write all AbstractTypes or error message to [outputFolder]. 33 | *
34 | * A folder named controller is created in [outputFolder]. 35 | * A File is written For each [Controller] or error message. 36 | * Controller metadata is written using [Controller.toDebugString]. 37 | */ 38 | internal fun List.writeOutput(outputFolder: File) { 39 | val folder = outputFolder.resolve("controller").maybeCreateFolder(clearIfExists = true) 40 | for((count, controllerOrError) in this.withIndex()) { 41 | when(controllerOrError){ 42 | is EitherOk -> { 43 | val name = "${count}_${controllerOrError.data.className.lowercase()}.txt" 44 | val text = controllerOrError.data.toDebugString() 45 | folder.resolve(name).maybeCreate().writeText(text) 46 | } 47 | is EitherNok -> { 48 | val name = "${count}_invalid.txt" 49 | val text = controllerOrError.data 50 | folder.resolve(name).maybeCreate().writeText(text) 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /lib/compiler/src/main/kotlin/dev/buijs/klutter/compiler/scanner/ControllerTypes.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.compiler.scanner 23 | 24 | import dev.buijs.klutter.kore.ast.* 25 | import dev.buijs.klutter.kore.common.Either 26 | import dev.buijs.klutter.kore.common.EitherNok 27 | import dev.buijs.klutter.kore.common.EitherOk 28 | 29 | /** 30 | * Alias for [Either] with only right value of type [Controller]. 31 | */ 32 | internal typealias ValidController = EitherOk 33 | 34 | /** 35 | * Alias for [Either] with only left value of type [String] (error). 36 | */ 37 | internal typealias InvalidController = EitherNok 38 | /** 39 | * Alias for [Either] with only right value of type [Method]. 40 | */ 41 | internal typealias ValidEvent = EitherOk 42 | 43 | /** 44 | * Alias for [Either] with only left value of type [String] (error). 45 | */ 46 | internal typealias InvalidEvent = EitherNok 47 | 48 | /** 49 | * Alias for [Either] containing a valid [Controller] or a [String] error message. 50 | */ 51 | internal typealias ValidControllerOrError = Either -------------------------------------------------------------------------------- /lib/compiler/src/main/kotlin/dev/buijs/klutter/compiler/scanner/EventResults.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.compiler.scanner 23 | 24 | import dev.buijs.klutter.compiler.wrapper.KAWrapper 25 | 26 | internal const val eventIsMissingReturnValue = 27 | "Event is missing a return value." 28 | 29 | internal const val eventHasUndeterminedMethodSignature = 30 | "Unable to determine method signature of Event." 31 | 32 | internal const val eventHasTooManyParameters = 33 | "Method has more than 1 parameter but only 0 or 1 is allowed." 34 | 35 | internal const val eventMethodConversionFailure = 36 | "Failed to convert Event to Method AST." 37 | 38 | internal fun KAWrapper.eventUnsupportedRequestParameterType() = 39 | InvalidEvent("Event ${method?.command} has a request parameter of an unsupported Type: '${method?.requestDataType}'") -------------------------------------------------------------------------------- /lib/compiler/src/main/kotlin/dev/buijs/klutter/compiler/validator/EventValidator.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.compiler.validator 2 | 3 | import dev.buijs.klutter.kore.ast.* 4 | 5 | internal fun AbstractType.isValidRequestParameterType(): Boolean { 6 | return when(this) { 7 | is CustomType, 8 | is EnumType, 9 | is BooleanType, 10 | is DoubleType, 11 | is IntType, 12 | is LongType, 13 | is StringType -> true 14 | is ListType -> { 15 | when(child) { 16 | is BooleanType, 17 | is DoubleType, 18 | is IntType, 19 | is LongType -> true 20 | else -> false 21 | } 22 | } 23 | else -> false 24 | } 25 | } -------------------------------------------------------------------------------- /lib/compiler/src/main/kotlin/dev/buijs/klutter/compiler/validator/Shared.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.compiler.validator 23 | 24 | import dev.buijs.klutter.kore.ast.CustomType 25 | 26 | internal fun MutableSet.addOrReplaceIfApplicable(type: CustomType): MutableSet { 27 | // CustomType with fields is present so break. 28 | if(this.contains(type)) return this 29 | 30 | // CustomType without fields is empty so replace with current. 31 | removeIf { it.className == type.className && it.members.isEmpty()} 32 | add(type) 33 | 34 | // Add all fields of type CustomType. 35 | for(field in type.members.map { it.type }.filterIsInstance()) { 36 | addOrReplaceIfApplicable(field) 37 | } 38 | 39 | return this 40 | } -------------------------------------------------------------------------------- /lib/compiler/src/main/kotlin/dev/buijs/klutter/compiler/wrapper/KCLogger.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.compiler.wrapper 2 | 3 | import com.google.devtools.ksp.processing.KSPLogger 4 | import dev.buijs.klutter.kore.common.maybeCreateFolder 5 | import dev.buijs.klutter.kore.project.klutterBomVersion 6 | import java.io.File 7 | 8 | class KCLogger( 9 | private val kspLogger: KSPLogger, 10 | outputFolder: File, 11 | ) { 12 | 13 | private val logFile = outputFolder 14 | .maybeCreateFolder(clearIfExists = true) 15 | .resolve("compiler.log") 16 | .also { if(it.exists()) it.delete() } 17 | .also { it.createNewFile() } 18 | .also { it.appendText("[INFO]: Execution by Compiler version $klutterBomVersion") } 19 | 20 | fun warn(message: String) { 21 | kspLogger.warn(message) 22 | writeWarning(message) 23 | } 24 | 25 | fun info(message: String) { 26 | kspLogger.info(message) 27 | writeInfo(message) 28 | } 29 | 30 | private fun writeWarning(message: String) { 31 | logFile.appendText("\n[WARN]: $message") 32 | } 33 | 34 | private fun writeInfo(message: String) { 35 | logFile.appendText("\n[INFO]: $message") 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /lib/compiler/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider: -------------------------------------------------------------------------------- 1 | dev.buijs.klutter.compiler.processor.ProcessorProvider -------------------------------------------------------------------------------- /lib/gradle/module.md: -------------------------------------------------------------------------------- 1 | # Klutter Gradle Plugin 2 | 3 | The main purpose of the Klutter Gradle Plugin is to connect a Flutter frontend with a Kotlin Multiplatform backend. 4 | This plugin provides a set of Gradle tasks which will generate anything from settings files to 5 | Kotlin/Dart/Groovy code needed to make Flutter and KMP work together. 6 | 7 | Important: For using and/or creating Flutter plugins with Klutter you should use the pub [plugin](https://github.com/buijs-dev/klutter-dart). 8 | 9 | ## Installation 10 | Preferred way of installing/using this plugin is by starting a new project with one of: 11 | - [Intellij](https://buijs.dev/klutter-3/) plugin 12 | - [Android Studio](https://buijs.dev/klutter-4/) plugin 13 | - [Kradle](https://buijs.dev/kradle-1/) cli tool 14 | 15 | ## Tasks 16 | The gradle plugin defines tasks for compiling the Kotlin Multiplatform module, 17 | generating Dart code and more. Some tasks are executed automatically before (compiler plugin) 18 | and after running a gradle build. 19 | 20 | 1. [klutterCompileProtoSchemas](#Task:%20klutterCompileProtoSchemas) 21 | 2. [klutterCopyAarFile](#Task:%20klutterCopyAarFile) 22 | 3. [klutterCopyFramework](#Task:%20klutterCopyFramework) 23 | 4. [klutterGenerateFlutterLib](#Task:%20klutterGenerateFlutterLib) 24 | 5. [klutterGenerateProtoSchemas](#Task:%20klutterGenerateProtoSchemas) 25 | 6. [klutterGetDartProtoc](#Task:%20klutterDartProtoc) 26 | 7. [klutterGetKradle](#Task:%20klutterGetKradle) 27 | 8. [klutterGetProtoc](#Task:%20klutterGetProtoc) 28 | 29 | # Task: klutterCompileProtoSchemas 30 | Compile protocol buffer schemas which generates boilerplate code for both Kotlin and Dart. 31 | This task does nothing when the protobuf feature is not enabled. 32 | 33 | # Task: klutterCopyAarFile 34 | Copy the root/platform aar file to root/android folder. 35 | 36 | # Task: klutterCopyFramework 37 | Copy the root/platform iOS Framework to root/ios folder. 38 | 39 | # Task: klutterGenerateFlutterLib 40 | Generate the Dart library file in the root/lib folder. 41 | 42 | # Task: klutterGenerateProtoSchemas 43 | Generate protocol buffer schemas which can be used by [klutterCompileProtoSchemas](#Task:%20klutterCompileProtoSchemas). 44 | This task does nothing when the protobuf feature is not enabled. 45 | 46 | # Task: klutterGetDartProtoc 47 | Download the dart protobuf plugin. 48 | 49 | # Task: klutterGetKradle 50 | Download the kradle cli tool. 51 | 52 | # Task: klutterGetProtoc 53 | Download the protoc executable tool. The distribution url can be specified 54 | in the kradle.env file: 55 | 56 | ```properties 57 | protoc.url=https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-osx-universal_binary.zip 58 | ``` 59 | -------------------------------------------------------------------------------- /lib/gradle/src/main/kotlin/dev/buijs/klutter/gradle/dsl/KlutterFeature.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.gradle.dsl 2 | 3 | enum class KlutterFeature { 4 | /** 5 | * Enable the protocol buffer feature. 6 | * 7 | * This replaces JSON (de)serialization as communication method between Kotlin and Dart. 8 | */ 9 | PROTOBUF 10 | } -------------------------------------------------------------------------------- /lib/gradle/src/main/kotlin/dev/buijs/klutter/gradle/dsl/KlutterPluginDSL.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.dsl 23 | 24 | @DslMarker 25 | internal annotation class KlutterPluginDSLMarker 26 | 27 | @KlutterPluginDSLMarker 28 | class KlutterPluginBuilder { 29 | 30 | var name: String = "" 31 | 32 | fun build() = Dto(name = name) 33 | 34 | } 35 | 36 | /** 37 | * DTO for storing Klutter plugin configuration. 38 | */ 39 | data class Dto(val name: String) -------------------------------------------------------------------------------- /lib/gradle/src/main/kotlin/dev/buijs/klutter/gradle/dsl/KlutterVersion.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.dsl 23 | 24 | import dev.buijs.klutter.kore.KlutterException 25 | import java.util.* 26 | 27 | internal object KlutterVersion { 28 | private val properties: Properties = Properties().also { 29 | it.load(KlutterDependencyHandler::class.java.classLoader.getResourceAsStream("publish.properties")) 30 | } 31 | 32 | @JvmStatic 33 | val annotations: String = getOrThrow("annotations.version") 34 | 35 | @JvmStatic 36 | val compiler: String = getOrThrow("compiler.version") 37 | 38 | @JvmStatic 39 | val kore: String = getOrThrow("kore.version") 40 | 41 | @JvmStatic 42 | val gradle: String = getOrThrow("plugin.gradle.version") 43 | 44 | @JvmStatic 45 | val kompose: String = getOrThrow("kompose.version") 46 | 47 | @JvmStatic 48 | val flutterEngine: String = getOrThrow("flutter.engine.version") 49 | 50 | @JvmStatic 51 | internal fun byName(simpleModuleName: String): String = when(simpleModuleName) { 52 | "annotations" -> annotations 53 | "kompose" -> kompose 54 | "kore" -> kore 55 | "gradle" -> gradle 56 | "compiler" -> compiler 57 | "flutter-engine-android" -> flutterEngine 58 | "flutter-engine-kmp-android" -> flutterEngine 59 | else -> throw KlutterException("Unknown module name '$simpleModuleName'.") 60 | } 61 | 62 | @JvmStatic 63 | internal fun getOrThrow(property: String): String = properties.getProperty(property) 64 | ?: throw KlutterException("Missing '$property' in Klutter Gradle Jar.") 65 | } -------------------------------------------------------------------------------- /lib/gradle/src/main/kotlin/dev/buijs/klutter/gradle/dsl/KotlinMultiplatformUtils.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.dsl 23 | 24 | import dev.buijs.klutter.kore.common.ExcludeFromJacocoGeneratedReport 25 | import org.gradle.api.Project 26 | import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension 27 | import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet 28 | 29 | @ExcludeFromJacocoGeneratedReport 30 | internal fun Project.findKotlinMultiplatformExtension(): KotlinMultiplatformExtension? = 31 | extensions.findByType(KotlinMultiplatformExtension::class.java) 32 | 33 | @ExcludeFromJacocoGeneratedReport 34 | internal fun Project.addKotlinMultiplatformDependency( 35 | sourceset: KotlinSourceSet, 36 | simpleModuleName: String, 37 | version: String, 38 | ) { 39 | sourceset.dependencies { 40 | implementation(createKlutterDependency(simpleModuleName, version)) 41 | } 42 | } 43 | 44 | @ExcludeFromJacocoGeneratedReport 45 | internal fun Project.addKotlinMultiplatformTestDependency( 46 | sourceset: KotlinSourceSet, 47 | simpleModuleName: String, 48 | version: String, 49 | ) { 50 | sourceset.dependencies { 51 | implementation(createKlutterDependency(simpleModuleName, version)) 52 | } 53 | } -------------------------------------------------------------------------------- /lib/gradle/src/main/kotlin/dev/buijs/klutter/gradle/tasks/CodeGenTasks.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.tasks 23 | 24 | import dev.buijs.klutter.gradle.dsl.KlutterVersion 25 | import dev.buijs.klutter.kore.KlutterTask 26 | import dev.buijs.klutter.kore.tasks.codegen.GenerateFlutterLibTask 27 | 28 | /** 29 | * Run the [GenerateFlutterLibTask] from Gradle. 30 | */ 31 | internal open class GenerateFlutterLibGradleTask: AbstractTask() { 32 | 33 | override val gradleTaskName = KlutterGradleTaskName.GenerateFlutterLib 34 | 35 | override fun klutterTask(): KlutterTask { 36 | val project = project() 37 | val root = project.root 38 | return GenerateFlutterLibTask( 39 | bomVersion = KlutterVersion.gradle, 40 | pluginName = root.pluginName, 41 | root = root, 42 | srcFolder = root.pathToLibFolder.resolve("src") 43 | ) 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /lib/gradle/src/main/kotlin/dev/buijs/klutter/gradle/tasks/CopyTasks.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.tasks 23 | 24 | import dev.buijs.klutter.kore.tasks.CopyAarFileTask 25 | import dev.buijs.klutter.kore.tasks.CopyXCFrameworkTask 26 | 27 | /** 28 | * Execute task [CopyAndroidAarFileGradleTask] from Gradle. 29 | */ 30 | internal open class CopyAndroidAarFileGradleTask : AbstractTask() { 31 | 32 | override val gradleTaskName = KlutterGradleTaskName.CopyAndroidAarFile 33 | 34 | override fun klutterTask() = CopyAarFileTask( 35 | pathToRoot = project.rootDir, 36 | pluginName = project.klutterExtension().plugin?.name, 37 | ) 38 | 39 | } 40 | 41 | /** 42 | * Execute task [CopyXCFrameworkTask] from Gradle. 43 | */ 44 | internal open class CopyIosFrameworkGradleTask : AbstractTask() { 45 | 46 | override val gradleTaskName = KlutterGradleTaskName.CopyIosFramework 47 | 48 | override fun klutterTask() = 49 | CopyXCFrameworkTask(project.rootDir) 50 | 51 | } -------------------------------------------------------------------------------- /lib/gradle/src/main/kotlin/dev/buijs/klutter/gradle/tasks/GetKradleGradleTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2024 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.tasks 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.tasks.GetKradleTask 26 | 27 | internal open class GetKradleGradleTask: AbstractTask() { 28 | 29 | override val gradleTaskName = KlutterGradleTaskName.GetKradle 30 | 31 | override fun klutterTask(): KlutterTask { 32 | val project = super.project() 33 | return GetKradleTask(project.root.resolve("kradle").absolutePath) 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /lib/gradle/src/main/resources/publish.properties: -------------------------------------------------------------------------------- 1 | annotations.version=2024.1.3.beta 2 | bom.version=2024.1.3.beta 3 | compiler.version=2024.1.3.beta 4 | flutter.engine.version=2024.1.2.beta 5 | kompose.version=2024.1.3.beta 6 | kore.version=2024.1.3.beta 7 | plugin.gradle.version=2024.1.3.beta 8 | plugin.jetbrains.version=2024.1.3.beta -------------------------------------------------------------------------------- /lib/gradle/src/test/groovy/dev/buijs/klutter/gradle/dsl/DependencyUtilsSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.dsl 23 | 24 | import spock.lang.Specification 25 | 26 | import java.nio.file.Files 27 | 28 | class DependencyUtilsSpec extends Specification { 29 | 30 | def "Verify embedded dependencies are retrieved successfully"() { 31 | 32 | given: 33 | def configFile = Files.createTempFile("", "").toFile() 34 | 35 | and: 36 | configFile.write(content) 37 | 38 | when: 39 | def embedded = DependencyUtilsKt.embeddedDependenciesFromConfigFile(configFile) 40 | 41 | then: 42 | embedded.size() == 1 43 | embedded[0] == "org.jetbrains.kotlinx:kotlinx-datetime:0.4.0" 44 | 45 | where: 46 | content = '''bom-version: "2023.1.2-SNAPSHOT" 47 | dependencies: 48 | klutter: "0.3.0" 49 | klutter_ui: "0.0.1" 50 | squint_json: "0.1.2" 51 | embedded: 52 | - "org.jetbrains.kotlinx:kotlinx-datetime:0.4.0"''' 53 | 54 | } 55 | 56 | 57 | def "Verify embedded dependencyNotation is bumped and not duplicated"() { 58 | 59 | given: 60 | def embedded = Set.of("foo:bar:001") 61 | 62 | when: 63 | def bumped = DependencyUtilsKt.bumpDependencyVersion(embedded,"foo:bar:002") 64 | 65 | then: 66 | bumped.size() == 1 67 | bumped[0] == "foo:bar:002" 68 | } 69 | 70 | 71 | } -------------------------------------------------------------------------------- /lib/gradle/src/test/groovy/dev/buijs/klutter/gradle/dsl/KlutterPluginDSLSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.gradle.dsl 2 | 3 | import spock.lang.Specification 4 | 5 | class KlutterPluginDSLSpec extends Specification { 6 | 7 | def "Verify a KlutterPluginDTO is created by using the KlutterPluginDSL" () { 8 | 9 | when: 10 | def dto = new KlutterPluginBuilder() 11 | dto.name = "awesome_plugin" 12 | 13 | then: 14 | dto.build().name == "awesome_plugin" 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /lib/gradle/src/test/groovy/dev/buijs/klutter/gradle/tasks/CodeGenTasksSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2024 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.tasks 23 | 24 | import dev.buijs.klutter.kore.tasks.codegen.GenerateFlutterLibTask 25 | import spock.lang.Specification 26 | 27 | import static dev.buijs.klutter.gradle.tasks.TaskTestUtil.verifyTask 28 | 29 | class CodeGenTasksSpec extends Specification { 30 | 31 | def "Verify GenerateFlutterLibGradleTask returns CopyAarFileTask"() { 32 | expect: 33 | verifyTask(GenerateFlutterLibGradleTask, GenerateFlutterLibTask) 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /lib/gradle/src/test/groovy/dev/buijs/klutter/gradle/tasks/CopyTasksSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2024 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.tasks 23 | 24 | 25 | import dev.buijs.klutter.kore.tasks.CopyAarFileTask 26 | import dev.buijs.klutter.kore.tasks.CopyXCFrameworkTask 27 | import spock.lang.Specification 28 | 29 | import static dev.buijs.klutter.gradle.tasks.TaskTestUtil.verifyTask 30 | 31 | class CopyTasksSpec extends Specification { 32 | 33 | def "Verify CopyAndroidAarFileGradleTask returns CopyAarFileTask"() { 34 | expect: 35 | verifyTask(CopyAndroidAarFileGradleTask, CopyAarFileTask) 36 | } 37 | 38 | def "Verify CopyIosFrameworkGradleTask returns CopyXCFrameworkTask"() { 39 | expect: 40 | verifyTask(CopyIosFrameworkGradleTask, CopyXCFrameworkTask) 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /lib/gradle/src/test/groovy/dev/buijs/klutter/gradle/tasks/GetKradleGradleTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.tasks 23 | 24 | import spock.lang.Ignore 25 | import spock.lang.Specification 26 | 27 | import static dev.buijs.klutter.gradle.tasks.TaskTestUtil.getTask 28 | 29 | class GetKradleGradleTaskSpec extends Specification { 30 | 31 | // does not work in ci yet ... 32 | @Ignore 33 | def "Verify getKradleTask works"() { 34 | def task = getTask(GetKradleGradleTask) 35 | 36 | when: 37 | task.execute() 38 | 39 | then: "No exception is thrown" 40 | 1 == 1 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /lib/gradle/src/test/groovy/dev/buijs/klutter/gradle/tasks/TaskTestUtil.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2024 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.gradle.tasks 23 | 24 | import dev.buijs.klutter.gradle.KlutterGradlePluginSpec 25 | 26 | class TaskTestUtil { 27 | static getTask(Class type) { 28 | def project = KlutterGradlePluginSpec.gradleProjectWithAppliedKlutterPlugin 29 | //noinspection ConfigurationAvoidance 30 | project.task('dummy', type: type) 31 | } 32 | 33 | static verifyTask(Class gradleTaskType, Class klutterTaskType) { 34 | def taskInstance = getTask(gradleTaskType) 35 | assert taskInstance.class.superclass == gradleTaskType 36 | assert taskInstance.klutterTask$gradle().class == klutterTaskType 37 | true 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/jetbrains/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .intellijPlatform 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/**/build/ 6 | !**/src/test/**/build/ 7 | 8 | ### IntelliJ IDEA ### 9 | .idea/modules.xml 10 | .idea/jarRepositories.xml 11 | .idea/compiler.xml 12 | .idea/libraries/ 13 | *.iws 14 | *.iml 15 | *.ipr 16 | out/ 17 | !**/src/main/**/out/ 18 | !**/src/test/**/out/ 19 | 20 | ### Eclipse ### 21 | .apt_generated 22 | .classpath 23 | .factorypath 24 | .project 25 | .settings 26 | .springBeans 27 | .sts4-cache 28 | bin/ 29 | !**/src/main/**/bin/ 30 | !**/src/test/**/bin/ 31 | 32 | ### NetBeans ### 33 | /nbproject/private/ 34 | /nbbuild/ 35 | /dist/ 36 | /nbdist/ 37 | /.nb-gradle/ 38 | 39 | ### VS Code ### 40 | .vscode/ 41 | 42 | ### Mac OS ### 43 | .DS_Store -------------------------------------------------------------------------------- /lib/jetbrains/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## [2024.1.2] 3 | 4 | ### Changed 5 | - Uses klutter 2024.1.2.beta. 6 | - Uses klutter (dart) [3.0.1](https://pub.dev/packages/klutter). 7 | 8 | ## [2024.1.1] 9 | 10 | ### Changed 11 | - Uses klutter 2024.1.1.beta. 12 | - Uses klutter (dart) [3.0.0](https://pub.dev/packages/klutter). 13 | - Uses klutter_ui (dart) [1.1.0](https://pub.dev/packages/klutter_ui). 14 | - Add protobuf support. 15 | 16 | ## [2023.3.1] 17 | 18 | ### Changed 19 | - Uses klutter 2023.3.1.beta. 20 | - Uses klutter (dart) [2.0.0](https://pub.dev/packages/klutter). 21 | - Uses klutter_ui (dart) [1.0.1](https://pub.dev/packages/klutter_ui). 22 | - Add live field validation in project wizard. 23 | - Add Flutter SDK distribution dropdown to project wizard. 24 | - Remove "New Klutter Project"-button from Welcome screen. 25 | 26 | ## [2023.2.1] 27 | 28 | ### Changed 29 | - Uses klutter 2023.2.1.beta. 30 | - Uses klutter (dart) [1.0.0](https://pub.dev/packages/klutter). 31 | - Uses klutter_ui (dart) [1.0.0](https://pub.dev/packages/klutter_ui). 32 | 33 | ## [2023.1.1] 34 | 35 | ### Changed 36 | - Uses klutter 2023.1.1.beta. 37 | - Uses klutter (dart) [0.3.0](https://pub.dev/packages/klutter). 38 | - Uses klutter_ui (dart) [0.0.3](https://pub.dev/packages/klutter_ui). 39 | - Uses squint_json (dart) [0.1.2](https://pub.dev/packages/squint_json). 40 | - Add option to get pub dependencies (see above) from git develop branches instead. 41 | - Add option to input klutter bom version. -------------------------------------------------------------------------------- /lib/jetbrains/module.md: -------------------------------------------------------------------------------- 1 | # Klutter UI: Kompose 2 | 3 | IDE support for Klutter -------------------------------------------------------------------------------- /lib/jetbrains/src/main/kotlin/dev/buijs/klutter/jetbrains/JetbrainsExecutor.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.jetbrains 23 | 24 | import com.intellij.execution.configurations.GeneralCommandLine 25 | import dev.buijs.klutter.kore.common.ExcludeFromJacocoGeneratedReport 26 | import dev.buijs.klutter.kore.tasks.Executor 27 | import dev.buijs.klutter.kore.tasks.finish 28 | import java.io.File 29 | 30 | @ExcludeFromJacocoGeneratedReport 31 | class JetbrainsExecutor: Executor() { 32 | 33 | override fun execute( 34 | runFrom: File, 35 | timeout: Long?, 36 | command: String, 37 | environment: Map, 38 | ): String = GeneralCommandLine(command.platformSpecific) 39 | .also { it.workDirectory = runFrom } 40 | .also { it.environment.putAll(environment) } 41 | .createProcess() 42 | .finish(timeout) 43 | 44 | } -------------------------------------------------------------------------------- /lib/jetbrains/src/main/kotlin/dev/buijs/klutter/jetbrains/KlutterMetadata.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.jetbrains 23 | 24 | import com.intellij.openapi.util.IconLoader 25 | import dev.buijs.klutter.kore.common.ExcludeFromJacocoGeneratedReport 26 | import javax.swing.Icon 27 | 28 | /** 29 | * Common text messages. 30 | */ 31 | @ExcludeFromJacocoGeneratedReport 32 | object KlutterBundle { 33 | 34 | const val moduleId: String = "KLUTTER_MODULE" 35 | 36 | const val bundleId: String = "buijs_software_klutter" 37 | 38 | const val presentableName: String = "Klutter" 39 | 40 | const val groupName: String = "Klutter Framework" 41 | 42 | const val descriptionShort: String = "Add support for the Klutter Framework" 43 | 44 | const val descriptionLong: String = "" + 45 | "Klutter is a framework which interconnects Flutter and Kotlin Multiplatform. " + 46 | "It can be used to create Flutter plugins or standalone apps." 47 | 48 | } 49 | 50 | /** 51 | * Klutter Logo's in Icon format. 52 | */ 53 | @ExcludeFromJacocoGeneratedReport 54 | object KlutterIcons { 55 | val logo16x16: Icon = IconLoader.getIcon("/pluginIcon16x16.svg", KlutterIcons::class.java) 56 | val logo20x20: Icon = IconLoader.getIcon("/pluginIcon20x20.svg", KlutterIcons::class.java) 57 | } -------------------------------------------------------------------------------- /lib/jetbrains/src/main/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Layer 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/jetbrains/src/main/resources/pluginIcon16x16.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/jetbrains/src/main/resources/pluginIcon20x20.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Layer 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/jetbrains/src/main/resources/pluginIcon512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/lib/jetbrains/src/main/resources/pluginIcon512x512.png -------------------------------------------------------------------------------- /lib/jetbrains/src/test/kotlin/dev/buijs/klutter/jetbrains/shared/KlutterMetadataTest.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.jetbrains.shared 2 | 3 | import dev.buijs.klutter.jetbrains.KlutterBundle 4 | import io.kotlintest.shouldBe 5 | import io.kotlintest.specs.WordSpec 6 | 7 | internal class KlutterMetadataTest: WordSpec({ 8 | 9 | "Verify KlutterBundle" should { 10 | 11 | "Return correct information" { 12 | KlutterBundle.moduleId shouldBe "KLUTTER_MODULE" 13 | KlutterBundle.bundleId shouldBe "buijs_software_klutter" 14 | KlutterBundle.presentableName shouldBe "Klutter" 15 | KlutterBundle.groupName shouldBe "Klutter Framework" 16 | KlutterBundle.descriptionShort shouldBe "Add support for the Klutter Framework" 17 | KlutterBundle.descriptionLong shouldBe "Klutter is a framework which interconnects Flutter and Kotlin Multiplatform. " + 18 | "It can be used to create Flutter plugins or standalone apps." 19 | 20 | } 21 | 22 | } 23 | 24 | }) -------------------------------------------------------------------------------- /lib/jetbrains/src/test/kotlin/dev/buijs/klutter/jetbrains/shared/NewProjectConfigValidatorTest.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.jetbrains.shared 2 | 3 | import dev.buijs.klutter.jetbrains.NewProjectConfig 4 | import dev.buijs.klutter.jetbrains.validate 5 | import dev.buijs.klutter.kore.project.FlutterDistributionFolderName 6 | import dev.buijs.klutter.kore.project.flutterDistribution 7 | import io.kotlintest.shouldBe 8 | import io.kotlintest.specs.WordSpec 9 | 10 | internal class NewProjectConfigValidatorTest: WordSpec({ 11 | 12 | "Verify validate" should { 13 | 14 | val dist = FlutterDistributionFolderName("3.0.5.macos.arm64").flutterDistribution 15 | 16 | "Return !isValid if group and name are not set" { 17 | NewProjectConfig().validate().isValid shouldBe false 18 | } 19 | 20 | "Use app- and groupname from KlutterTaskConfig if not null" { 21 | NewProjectConfig( 22 | appName = "my_plugin_project", 23 | groupName = "com.example.my_plugin.project", 24 | flutterDistribution = dist 25 | ).validate().isValid shouldBe true 26 | } 27 | 28 | "Return false if one or more validations fail" { 29 | 30 | // given an invalid app name and valid group name 31 | var config = NewProjectConfig( 32 | appName = "_invalid_project.name!!!", 33 | groupName = "com.example.my_plugin.project", 34 | flutterDistribution = dist 35 | ) 36 | 37 | // expect validation to fail 38 | config.validate().isValid shouldBe false 39 | 40 | // given a valid app name and invalid group name 41 | config = NewProjectConfig( 42 | appName = "my_plugin_project", 43 | groupName = "com_._!example.my_plugin.project", 44 | flutterDistribution = dist 45 | ) 46 | 47 | // expect validation to fail 48 | config.validate().isValid shouldBe false 49 | 50 | // given an invalid app name and invalid group name 51 | config = NewProjectConfig( 52 | appName = "_invalid_project!!!", 53 | groupName = "com_._!example.my_plugin.project", 54 | flutterDistribution = dist 55 | ) 56 | 57 | // expect validation to fail 58 | config.validate().isValid shouldBe false 59 | 60 | } 61 | 62 | } 63 | 64 | }) -------------------------------------------------------------------------------- /lib/jetbrains/src/test/kotlin/dev/buijs/klutter/jetbrains/systemtest/utils/RemoteRobotExtension.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.jetbrains.systemtest.utils 2 | 3 | import com.intellij.remoterobot.RemoteRobot 4 | import org.junit.jupiter.api.extension.AfterTestExecutionCallback 5 | import org.junit.jupiter.api.extension.ExtensionContext 6 | import org.junit.jupiter.api.extension.ParameterContext 7 | import org.junit.jupiter.api.extension.ParameterResolver 8 | 9 | class RemoteRobotExtension: AfterTestExecutionCallback, ParameterResolver { 10 | 11 | private val url 12 | get() = System.getProperty("remote-robot-url") 13 | ?: "http://127.0.0.1:8082" 14 | 15 | internal val remoteRobot 16 | get() = RemoteRobot(url) 17 | 18 | override fun supportsParameter( 19 | parameterContext: ParameterContext?, 20 | extensionContext: ExtensionContext?, 21 | ): Boolean = parameterContext 22 | ?.parameter 23 | ?.type 24 | ?.equals(RemoteRobot::class.java) 25 | ?: false 26 | 27 | override fun resolveParameter( 28 | parameterContext: ParameterContext?, 29 | extensionContext: ExtensionContext?, 30 | ) = remoteRobot 31 | 32 | override fun afterTestExecution( 33 | context: ExtensionContext? 34 | ) { 35 | // nothing 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /lib/jetbrains/src/test/kotlin/dev/buijs/klutter/jetbrains/systemtest/utils/StepsLogger.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.jetbrains.systemtest.utils 2 | 3 | import com.intellij.remoterobot.stepsProcessing.StepLogger 4 | import com.intellij.remoterobot.stepsProcessing.StepWorker 5 | 6 | object StepsLogger { 7 | private var initialized = false 8 | @JvmStatic 9 | fun init() { 10 | if (initialized.not()) { 11 | StepWorker.registerProcessor(StepLogger()) 12 | initialized = true 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /lib/kompose/kompose.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'kompose' 3 | spec.version = '2024.1.3.beta' 4 | spec.homepage = 'https://buijs.dev' 5 | spec.source = { :http=> ''} 6 | spec.authors = '' 7 | spec.license = '' 8 | spec.summary = 'Klutter Kompose module' 9 | spec.vendored_frameworks = 'build/cocoapods/framework/Kompose.framework' 10 | spec.libraries = 'c++' 11 | spec.ios.deployment_target = '9.0' 12 | 13 | 14 | spec.pod_target_xcconfig = { 15 | 'KOTLIN_PROJECT_PATH' => ':lib:kompose', 16 | 'PRODUCT_MODULE_NAME' => 'Kompose', 17 | } 18 | 19 | spec.script_phases = [ 20 | { 21 | :name => 'Build kompose', 22 | :execution_position => :before_compile, 23 | :shell_path => '/bin/sh', 24 | :script => <<-SCRIPT 25 | if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then 26 | echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" 27 | exit 0 28 | fi 29 | set -ev 30 | REPO_ROOT="$PODS_TARGET_SRCROOT" 31 | "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ 32 | -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ 33 | -Pkotlin.native.cocoapods.archs="$ARCHS" \ 34 | -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" 35 | SCRIPT 36 | } 37 | ] 38 | 39 | end -------------------------------------------------------------------------------- /lib/kompose/module.md: -------------------------------------------------------------------------------- 1 | # Klutter UI: Kompose 2 | 3 | Bind stateless Flutter Widgets to viewmodels in Kotlin. -------------------------------------------------------------------------------- /lib/kompose/src/commonMain/kotlin/dev/buijs/klutter/kompose/IosFlow.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kompose 23 | 24 | import kotlinx.coroutines.* 25 | import kotlinx.coroutines.flow.Flow 26 | 27 | class IosFlow(source: Flow): Flow by source { 28 | 29 | fun collect( 30 | onEach: (T) -> Unit, 31 | onCompletion: (cause: Throwable?) -> Unit, 32 | ) = object : Cancellable { 33 | 34 | private val scope = CoroutineScope( 35 | SupervisorJob() + Dispatchers.Main 36 | ) 37 | 38 | init { 39 | scope.launch { collect() } 40 | } 41 | 42 | private suspend fun collect() { 43 | try { 44 | collect { onEach(it) } 45 | onCompletion(null) 46 | } catch (e: Throwable) { 47 | onCompletion(e) 48 | } 49 | } 50 | 51 | override fun cancel() = scope.cancel() 52 | 53 | } 54 | } 55 | 56 | interface Cancellable { 57 | fun cancel() 58 | } -------------------------------------------------------------------------------- /lib/kore/module.md: -------------------------------------------------------------------------------- 1 | # Klutter Kore 2 | 3 | This module contains the core classes Klutter is build on. -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/Exception.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | 23 | package dev.buijs.klutter.kore 24 | 25 | /** 26 | * Exception class indicating a terminal problem in the Klutter Framework. 27 | */ 28 | class KlutterException(msg: String, throwable: Throwable? = null): Exception(msg, throwable) -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/Interfaces.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | 23 | package dev.buijs.klutter.kore 24 | 25 | /** 26 | * Utility interface which takes (generated) file content and writes it to a file. 27 | * 28 | * Used for editing and/or creating classes and configuration files. 29 | */ 30 | interface KlutterWriter { 31 | 32 | /** 33 | * Creates a new file and writes the content to said file. 34 | */ 35 | fun write() 36 | 37 | } 38 | 39 | /** 40 | * Output the content of a (to be created) class. 41 | */ 42 | interface KlutterPrinter { 43 | 44 | /** 45 | * @return the created file content as String. 46 | */ 47 | fun print(): String 48 | 49 | } 50 | 51 | /** 52 | * Class which contains all logic to fully execute a functional task. 53 | */ 54 | interface KlutterTask { 55 | 56 | fun run() 57 | 58 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/ast/FlutterChannel.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.ast 2 | 3 | sealed interface FlutterChannel { 4 | val name: String 5 | } 6 | 7 | data class FlutterAsyncChannel( 8 | override val name: String 9 | ): FlutterChannel 10 | 11 | data class FlutterSyncChannel( 12 | override val name: String 13 | ): FlutterChannel -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/ast/StandardTypeMap.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.ast 23 | 24 | import dev.buijs.klutter.kore.KlutterException 25 | 26 | /** 27 | * This is not an exhaustive mapping but a basic mapping to 28 | * facilitate converting Kotlin DTO classes to Dart DTO classes. 29 | */ 30 | internal enum class StandardTypeMap( 31 | val kotlinType: String, 32 | val dartType: String, 33 | ) { 34 | 35 | INTEGER("Int", "int"), 36 | DOUBLE("Double", "double"), 37 | BOOLEAN("Boolean", "bool"), 38 | STRING("String", "String"), 39 | NOTHING("Unit", "void"), 40 | LONG("Long", "int"), 41 | BYTE_ARRAY("ByteArray", "Uint8List"), 42 | INT_ARRAY("IntArray", "Int32List"), 43 | LONG_ARRAY("LongArray", "Int64List"), 44 | FLOAT_ARRAY("FloatArray", "Float32List"), 45 | DOUBLE_ARRAY("DoubleArray", "Float64List"), 46 | LIST("List", "List"), 47 | MAP("Map", "Map"); 48 | 49 | companion object { 50 | 51 | @JvmStatic 52 | fun toKotlinType(type: String) = toMap(type).kotlinType 53 | 54 | @JvmStatic 55 | fun toDartType(type: String) = toMap(type).dartType 56 | 57 | @JvmStatic 58 | fun toMap(type: String) = toMapOrNull(type) 59 | ?: throw KlutterException("No such type in KotlinDartMap: $type") 60 | 61 | @JvmStatic 62 | fun toMapOrNull(type: String) = values() 63 | .firstOrNull { it.dartType == type || it.kotlinType == type} 64 | 65 | @JvmStatic 66 | fun fromKotlinTypeOrNull(type: String) = values() 67 | .firstOrNull { it.kotlinType == type} 68 | } 69 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/common/Either.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.common 23 | 24 | sealed class Either { 25 | companion object { 26 | @JvmStatic 27 | fun ok(data: R) = EitherOk(data) 28 | 29 | @JvmStatic 30 | fun nok(data: T) = EitherNok(data) 31 | } 32 | } 33 | 34 | data class EitherOk(val data: R): Either() 35 | 36 | data class EitherNok(val data: T): Either() -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/common/ExcludeJacoco.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.common 23 | 24 | import java.lang.annotation.Inherited 25 | 26 | @Inherited 27 | @Retention(AnnotationRetention.RUNTIME) 28 | @Target(AnnotationTarget.FILE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) 29 | annotation class ExcludeFromJacocoGeneratedReport(val reason: String = "") -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/common/JsonFormat.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.common 23 | 24 | import kotlinx.serialization.ExperimentalSerializationApi 25 | import kotlinx.serialization.json.Json 26 | 27 | @OptIn(ExperimentalSerializationApi::class) 28 | val JSON = Json { explicitNulls = false } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/common/StringUtils.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.common 23 | 24 | fun String.prefixIfNot(prefix: String) = 25 | if(startsWith(prefix)) this else "$prefix$this" 26 | 27 | fun String.removeSuffixIfPresent(suffix: String) = 28 | if(endsWith(suffix)) this.substringBeforeLast(suffix) else this 29 | 30 | /** 31 | * Convert a String to camelCase. 32 | */ 33 | fun String.toCamelCase(): String { 34 | 35 | var hasUnderscore = false 36 | 37 | return lowercase().map { 38 | when { 39 | 40 | it == '_' -> { 41 | hasUnderscore = true 42 | "" 43 | } 44 | 45 | hasUnderscore -> { 46 | hasUnderscore = false 47 | it.uppercase() 48 | } 49 | 50 | else -> it.toString() 51 | } 52 | }.joinToString("") { it } 53 | 54 | } 55 | 56 | private val isAlphabeticRegex = """^[a-zA-Z]$""".toRegex() 57 | 58 | /** 59 | * Convert a String to snake_case. 60 | */ 61 | fun String.toSnakeCase(): String = mapIndexed { index, char -> 62 | when { 63 | index == 0 -> char.lowercase() 64 | 65 | !isAlphabeticRegex.matches("$char") -> char 66 | 67 | char.uppercase() == "$char" -> "_${char.lowercase()}" 68 | 69 | else -> char 70 | } 71 | }.map { "$it" }.joinToString("") { it } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/project/Android.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | 23 | package dev.buijs.klutter.kore.project 24 | 25 | import dev.buijs.klutter.kore.common.verifyExists 26 | import java.io.File 27 | 28 | /** 29 | * Wrapper class with a file instance pointing to the android submodule. 30 | * 31 | * @property folder path to the Android folder. 32 | */ 33 | class Android( 34 | val folder: File, 35 | val pluginPackageName: String, 36 | val pluginClassName: String, 37 | ) { 38 | 39 | val pathToPluginPackage: File = folder 40 | .resolve("src/main/kotlin/${pluginPackageName.toPath()}") 41 | .verifyExists() 42 | 43 | val pathToPlugin: File = pathToPluginPackage 44 | .resolve("$pluginClassName.kt") 45 | 46 | } 47 | 48 | internal fun String?.toPath(): String { 49 | return (this ?: "").replace(".", "/") 50 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/project/Environment.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.project 2 | 3 | import dev.buijs.klutter.kore.KlutterException 4 | import dev.buijs.klutter.kore.tasks.execute 5 | import java.io.File 6 | import java.nio.file.Path 7 | 8 | enum class OperatingSystem(val value: String) { 9 | WINDOWS("windows"), 10 | MACOS("macos"), 11 | LINUX("linux") 12 | } 13 | 14 | enum class Architecture { 15 | X64, 16 | ARM64, 17 | } 18 | 19 | data class Version( 20 | val major: Int, 21 | val minor: Int, 22 | val patch: Int, 23 | ) 24 | 25 | val Version.prettyPrint: String 26 | get() = "${major}.${minor}.${patch}" 27 | 28 | val isWindows: Boolean 29 | get() = currentOperatingSystem == OperatingSystem.WINDOWS 30 | 31 | val isMacos: Boolean 32 | get() = currentOperatingSystem == OperatingSystem.MACOS 33 | 34 | /** 35 | * Get current [OperatingSystem] from System Properties. 36 | * 37 | * @returns [OperatingSystem]. 38 | * @throws [KlutterException] Unsupported OperatingSystem if not one of [OperatingSystem]. 39 | */ 40 | val currentOperatingSystem: OperatingSystem 41 | get() = System.getProperty("os.name").uppercase().let { screaming -> 42 | when { 43 | screaming.contains("WIN") -> OperatingSystem.WINDOWS 44 | screaming.contains("MAC") -> OperatingSystem.MACOS 45 | screaming.contains("LINUX") -> OperatingSystem.LINUX 46 | else -> throw KlutterException("Unsupported OperatingSystem: $screaming") 47 | } 48 | } 49 | 50 | val currentArchitecture: Architecture 51 | get() { 52 | val sysctl = "sysctl -n sysctl.proc_translated" execute currentWorkingDirectory 53 | val usesRosetta = sysctl == "1" 54 | val architecture = """uname -m""" execute currentWorkingDirectory 55 | val archContainsARM = architecture.uppercase().contains("ARM") 56 | return when { 57 | usesRosetta -> Architecture.ARM64 58 | archContainsARM -> Architecture.ARM64 59 | else -> Architecture.X64 60 | } 61 | } 62 | 63 | val currentWorkingDirectory: File 64 | get() = Path.of("").toFile().absoluteFile -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/project/Platform.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | 23 | package dev.buijs.klutter.kore.project 24 | 25 | import dev.buijs.klutter.kore.KlutterException 26 | import dev.buijs.klutter.kore.common.verifyExists 27 | import java.io.File 28 | 29 | /** 30 | * Wrapper class with a file instance pointing to the kmp sub-module in root/platform. 31 | * 32 | * @property folder path to the Platform folder. 33 | */ 34 | class Platform( 35 | val folder: File, 36 | private val pluginName: String, 37 | ) { 38 | 39 | /** 40 | * Function to return the location of the src module containing the common/shared platform code. 41 | * 42 | * @throws KlutterException if file(s) do not exist. 43 | * @return the absolute path to the common source code. 44 | */ 45 | fun source() = folder 46 | .verifyExists() 47 | .resolve("src/commonMain") 48 | .verifyExists() 49 | 50 | /** 51 | * Function to return the location of the podspec in the platform sub-module. 52 | * 53 | * @throws KlutterException if file(s) do not exist. 54 | * @return the absolute path to the ios Podfile. 55 | */ 56 | fun podspec() = folder 57 | .verifyExists() 58 | .resolve("$pluginName.podspec") 59 | .verifyExists() 60 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/project/Root.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.project 23 | 24 | import dev.buijs.klutter.kore.KlutterException 25 | import dev.buijs.klutter.kore.common.toCamelCase 26 | import java.io.File 27 | 28 | const val kspArgumentKlutterProjectFolder = "klutterProjectFolder" 29 | 30 | /** 31 | * @property folder path to the top level of the project. 32 | */ 33 | class Root(val pluginName: String, file: File) { 34 | 35 | val folder: File = 36 | if (!file.exists()) { 37 | throw KlutterException("The root folder does not exist: ${file.absolutePath}.") 38 | } else { 39 | file.absoluteFile 40 | } 41 | 42 | val pathToLibFolder = resolve("lib") 43 | 44 | val pathToLibFile = resolve("lib/$pluginName.dart") 45 | 46 | val pluginClassName = pluginName 47 | .toCamelCase() 48 | .replaceFirstChar { it.uppercase() } 49 | 50 | fun resolve(to: String): File = folder.resolve(to).normalize().absoluteFile 51 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/CopyAarFileTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.common.verifyExists 26 | import java.io.File 27 | 28 | /** 29 | * Copy the platform release aar file build in the platform module 30 | * to the plugin android/Klutter folder. 31 | */ 32 | class CopyAarFileTask( 33 | private val pathToRoot: File, 34 | private val pluginName: String? = null, 35 | ): KlutterTask { 36 | 37 | private val pathToTarget: String = "" 38 | 39 | private val pathToSource: String = "platform" 40 | 41 | override fun run() { 42 | val name = pluginName ?: "platform" 43 | 44 | val pathToAarFile = pathToRoot 45 | .resolve(pathToSource) 46 | .resolve("build/outputs/aar/$name-release.aar") 47 | .verifyExists() 48 | 49 | val target = pathToRoot 50 | .resolve(pathToTarget) 51 | .resolve("android/klutter") 52 | .verifyExists() 53 | .resolve("platform.aar") 54 | .also { if(it.exists()) it.delete() } 55 | 56 | pathToAarFile.copyTo(target) 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/CopyXCFrameworkTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.common.verifyExists 26 | import dev.buijs.klutter.kore.project.isWindows 27 | import java.io.File 28 | 29 | /** 30 | * Copy the 'Platform.xcframework' build in the platform module 31 | * to the plugin ios/Klutter folder. 32 | */ 33 | class CopyXCFrameworkTask( 34 | private val pathToRoot: File, 35 | ): KlutterTask { 36 | 37 | private val pathToTarget: String = "" 38 | 39 | private val pathToSource: String = "platform" 40 | 41 | override fun run() { 42 | // XCFramework can not be build on Windows. 43 | if(isWindows) return 44 | 45 | val target = pathToRoot 46 | .resolve(pathToTarget) 47 | .resolve("ios/Klutter") 48 | .verifyExists() 49 | .resolve("Platform.xcframework") 50 | .also { if(it.exists()) it.deleteRecursively() } 51 | 52 | val pathToIosFramework = pathToRoot 53 | .resolve(pathToSource) 54 | .resolve("build/XCFrameworks/release/Platform.xcframework") 55 | .verifyExists() 56 | 57 | pathToIosFramework.copyRecursively(target) 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/DownloadProtocTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.tasks.project.DownloadProtoc 26 | import java.io.File 27 | 28 | /** 29 | * Download a protoc distribution which is required to use 30 | * protocol buffers in a klutter project. 31 | */ 32 | class DownloadProtocTask( 33 | private val rootFolder: File, 34 | private val overwrite: Boolean = false, 35 | private val target: File 36 | ) : KlutterTask { 37 | override fun run() { 38 | DownloadProtoc(rootFolder, overwrite, target).doAction() 39 | } 40 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/GetDartProtocExeTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks 23 | 24 | import dev.buijs.klutter.kore.KlutterException 25 | import dev.buijs.klutter.kore.KlutterTask 26 | import dev.buijs.klutter.kore.common.maybeCreateFolder 27 | import dev.buijs.klutter.kore.common.verifyExists 28 | import dev.buijs.klutter.kore.project.kradleHome 29 | 30 | /** 31 | * Task to extract the dart protoc executable. 32 | */ 33 | class GetDartProtocExeTask: KlutterTask { 34 | 35 | private val pathToExecutableFile = this::class.java.classLoader 36 | .getResourceAsStream("protoc_plugin.exe") 37 | ?: throw KlutterException("File protoc_plugin.exe is missing from Resources!") 38 | 39 | override fun run() { 40 | 41 | val parentFolder = kradleHome 42 | .resolve(".cache") 43 | .resolve("protobuf") 44 | .maybeCreateFolder() 45 | 46 | val target = parentFolder 47 | .resolve("protoc_plugin.exe") 48 | 49 | if(!target.exists()) { 50 | pathToExecutableFile.copyTo(target.outputStream()) 51 | target.setExecutable(true) 52 | if(!target.canExecute()) 53 | throw KlutterException("Failed to make File protoc_plugin executable") 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/codegen/DartFormatTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.common.* 26 | import dev.buijs.klutter.kore.project.FlutterDistributionFolderName 27 | import dev.buijs.klutter.kore.project.dartExecutable 28 | import dev.buijs.klutter.kore.tasks.execute 29 | import java.io.File 30 | 31 | fun GenerateCodeOptions.toDartFormatTask() = 32 | DartFormatTask(flutterLibFolder, flutterFolder, log) 33 | 34 | /** 35 | * Run command 'dart format .' in a folder. 36 | */ 37 | class DartFormatTask( 38 | private val folder: File, 39 | flutterFolder: FlutterDistributionFolderName, 40 | private val log: (String) -> Unit = { }, 41 | ) : KlutterTask, GenerateCodeAction { 42 | 43 | private val dart = dartExecutable(flutterFolder).absolutePath 44 | 45 | override fun run() { 46 | "$dart format .".execute(folder.verifyExists()).also { log(it) } 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/codegen/GenerateAndroidLibTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.ast.* 26 | import dev.buijs.klutter.kore.common.* 27 | import dev.buijs.klutter.kore.project.* 28 | import dev.buijs.klutter.kore.templates.AndroidAdapter 29 | 30 | fun GenerateCodeOptions.toGenerateAndroidLibTask() = 31 | GenerateAndroidLibTask(android = project.android, bindings = bindings, isProtobufEnabled = responseClassNames.isNotEmpty()) 32 | 33 | /** 34 | * Generate the Android code in root/android. 35 | */ 36 | class GenerateAndroidLibTask( 37 | private val android: Android, 38 | private val bindings: Map>, 39 | private val isProtobufEnabled: Boolean, 40 | ) : KlutterTask, GenerateCodeAction { 41 | override fun run() { 42 | android.pathToPlugin.maybeCreate().write( 43 | AndroidAdapter( 44 | pluginClassName = android.pluginClassName, 45 | pluginPackageName = android.pluginPackageName, 46 | methodChannels = bindings.values.flatten().filterIsInstance().map { it.name }.toSet(), 47 | eventChannels = bindings.values.flatten().filterIsInstance().map { it.name }.toSet(), 48 | controllers = bindings.keys, 49 | isProtobufEnabled = isProtobufEnabled)) 50 | } 51 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/codegen/GenerateCodeTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | 26 | fun GenerateCodeOptions.toGenerateCodeTask() = 27 | GenerateCodeTask(options = this) 28 | 29 | /** 30 | * Task to generate the boilerplate code required to let Kotlin Multiplatform and Flutter communicate. 31 | */ 32 | class GenerateCodeTask( 33 | private val options: GenerateCodeOptions 34 | ) : KlutterTask, GenerateCodeAction { 35 | 36 | override fun run() { 37 | options.clearFlutterLibFolder() 38 | options.clearFlutterSrcFolder() 39 | runGenerateCodeActions( 40 | findGenerateCodeAction(options), 41 | findGenerateCodeAction(options), 42 | findGenerateCodeAction(options), 43 | findGenerateCodeAction(options), 44 | findGenerateCodeAction(options), 45 | findGenerateCodeAction(options), 46 | findGenerateCodeAction(options), 47 | findGenerateCodeAction(options), 48 | findGenerateCodeAction(options)) 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/codegen/GenerateFlutterLibTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.common.* 26 | import dev.buijs.klutter.kore.project.* 27 | import dev.buijs.klutter.kore.templates.flutter.PackageLib 28 | import java.io.File 29 | 30 | fun GenerateCodeOptions.toGenerateFlutterLibTask() = 31 | GenerateFlutterLibTask(root = project.root, 32 | srcFolder = flutterSrcFolder, 33 | bomVersion = klutterBomVersion, 34 | pluginName = pluginName) 35 | 36 | /** 37 | * Generate the Flutter (dart) code in root/lib folder of the plugin project. 38 | */ 39 | class GenerateFlutterLibTask( 40 | private val root: Root, 41 | private val srcFolder: File, 42 | private val pluginName: String, 43 | private val bomVersion: String, 44 | ) : KlutterTask, GenerateCodeAction { 45 | 46 | override fun run() { 47 | // Update Klutter Gradle Plugin Version 48 | root.kradleYaml.let { kradleYamlFile -> 49 | kradleYamlFile.toConfigOrNull() 50 | ?.copy(bomVersion = bomVersion) 51 | ?.let { kradleYamlFile.writeText(mapper.writeValueAsString(it)) } 52 | } 53 | 54 | root.pathToLibFile.maybeCreate().write( 55 | PackageLib( 56 | name = pluginName, 57 | exports = srcFolder.verifyExists().walkTopDown() 58 | .toList() 59 | .filter { it.isFile } 60 | .map { it.relativeTo(srcFolder) } 61 | .map { it.path.prefixIfNot("src/").replace("""\""", "/") })) 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/codegen/GenerateIosLibTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.ast.* 26 | import dev.buijs.klutter.kore.common.* 27 | import dev.buijs.klutter.kore.project.* 28 | import dev.buijs.klutter.kore.templates.IosAdapter 29 | 30 | fun GenerateCodeOptions.toGenerateIosLibTask() = 31 | GenerateIosLibTask( 32 | ios = project.ios, 33 | bindings = bindings, 34 | isProtobufEnabled = responseClassNames.isNotEmpty()) 35 | 36 | /** 37 | * Generate the IOS code in root/ios. 38 | */ 39 | class GenerateIosLibTask( 40 | private val ios: IOS, 41 | private val bindings: Map>, 42 | private val isProtobufEnabled: Boolean, 43 | ) : KlutterTask, GenerateCodeAction { 44 | override fun run() { 45 | ios.pathToPlugin.maybeCreate().write( 46 | IosAdapter( 47 | pluginClassName = ios.pluginClassName, 48 | methodChannels = bindings.values.flatten().filterIsInstance().map { it.name }.toSet(), 49 | eventChannels = bindings.values.flatten().filterIsInstance().map { it.name }.toSet(), 50 | controllers = bindings.keys, 51 | isProtobufEnabled = isProtobufEnabled)) 52 | } 53 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/codegen/GenerateProtoExtensionsTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2024 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.common.maybeCreate 26 | import dev.buijs.klutter.kore.common.maybeCreateFolder 27 | import dev.buijs.klutter.kore.common.write 28 | import dev.buijs.klutter.kore.templates.ProtobufExtensions 29 | import java.io.File 30 | 31 | const val protoGenMarker = "ProtocolBufferGenerated" 32 | 33 | fun GenerateCodeOptions.toGenerateProtoExtensionsTask() = 34 | GenerateProtoExtensionsTask(project.platform.folder 35 | .resolve("build") 36 | .resolve("generated") 37 | .resolve("ksp") 38 | .resolve("metadata") 39 | .resolve("commonMain") 40 | .resolve("kotlin") 41 | , responseClassNames) 42 | 43 | class GenerateProtoExtensionsTask( 44 | private val sourceFolder: File, 45 | private val responseClassNames: List, 46 | ) : KlutterTask, GenerateCodeAction { 47 | override fun run() { 48 | for(fqdn in responseClassNames) { 49 | val packageName = fqdn 50 | .substringBeforeLast(".") 51 | 52 | val pathToPackage = packageName 53 | .replace(".", "/") 54 | 55 | val className = fqdn.substringAfterLast(".") 56 | 57 | sourceFolder 58 | .resolve(pathToPackage) 59 | .maybeCreateFolder() 60 | .resolve("$protoGenMarker$className.kt") 61 | .maybeCreate() 62 | .write(ProtobufExtensions(packageName, className)) 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/codegen/PubGetTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.project.FlutterDistributionFolderName 26 | import dev.buijs.klutter.kore.project.flutterExecutable 27 | import dev.buijs.klutter.kore.tasks.execute 28 | import java.io.File 29 | 30 | fun GenerateCodeOptions.toPubGetTask() = 31 | PubGetTask(project.root.folder, flutterFolder,log) 32 | 33 | /** 34 | * Run command 'flutter pub get' in a folder. 35 | */ 36 | class PubGetTask( 37 | private val folder: File, 38 | flutterFolder: FlutterDistributionFolderName, 39 | private val log: (String) -> Unit = { }, 40 | ) : KlutterTask, GenerateCodeAction { 41 | 42 | private val flutter = flutterExecutable(flutterFolder).absolutePath 43 | 44 | override fun run() { 45 | "$flutter pub get".execute(folder).also { log(it) } 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/ActionFlutterCreate.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.project.FlutterDistribution 25 | import dev.buijs.klutter.kore.project.flutterExecutable 26 | import dev.buijs.klutter.kore.project.folderNameString 27 | import dev.buijs.klutter.kore.tasks.execute 28 | 29 | internal fun ProjectBuilderOptions.toRunFlutterAction() = 30 | RunFlutterCreate(pluginName, groupName, rootFolder, flutterFolder) 31 | 32 | internal class RunFlutterCreate( 33 | private val pluginName: PluginName, 34 | private val groupName: GroupName, 35 | private val rootFolder: RootFolder, 36 | private val flutterDistribution: FlutterDistribution, 37 | ): ProjectBuilderAction { 38 | 39 | override fun doAction() { 40 | val flutter = flutterExecutable(flutterDistribution.folderNameString).absolutePath 41 | 42 | val validRootFolder = rootFolder.validRootFolderOrThrow() 43 | 44 | val validPluginName = pluginName.validPluginNameOrThrow() 45 | 46 | val validGroupName = groupName.validGroupNameOrThrow() 47 | 48 | "$flutter create $validPluginName " + 49 | "--org $validGroupName " + 50 | "--template=plugin " + 51 | "--platforms=android,ios " + 52 | "-a kotlin -i swift" execute validRootFolder 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/DownloadFlutterTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | import dev.buijs.klutter.kore.project.FlutterDistribution 26 | import java.io.File 27 | 28 | /** 29 | * Task to download a compatible Flutter distribution. 30 | */ 31 | class DownloadFlutterTask( 32 | private val flutter: FlutterDistribution, 33 | private val overwrite: Boolean = false, 34 | 35 | /** 36 | * Folder to download the SDK to. 37 | * 38 | * Defaults to the Klutter .cache folder. 39 | */ 40 | private val target: File? = null 41 | 42 | ) : KlutterTask { 43 | override fun run() { 44 | DownloadFlutter(flutter, overwrite, target).doAction() 45 | } 46 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/InputFlutterPath.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.common.Either 25 | import java.io.File 26 | 27 | typealias FlutterPath = Either 28 | 29 | fun toFlutterPath(value: String) = value.toInput() 30 | 31 | private fun String.toInput(): RootFolder { 32 | val file = File(this) 33 | return if(!file.exists()) 34 | FlutterPath.nok("Flutter distribution does not exist: '$this'") 35 | else FlutterPath.ok(file) 36 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/InputGroupName.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.common.Either 25 | 26 | typealias GroupName = Either 27 | 28 | fun toGroupName(value: String) = value.toInput() 29 | 30 | /** 31 | * Validate a Klutter group name with the following constraints: 32 | * - All characters are lowercase 33 | * - All characters are: 34 | * - alphabetic or 35 | * - numeric or 36 | * - '_' or 37 | * - '.' 38 | * 39 | * - Group contains at least 2 parts (e.g. there is minimally 1 dot) 40 | * - Should start with an alphabetic character 41 | */ 42 | private fun String.toInput(): GroupName { 43 | 44 | if(!contains(".")) 45 | return GroupName.nok("GroupName error: Should contain at least 2 parts ('com.example').") 46 | 47 | if(contains("_.")) 48 | return GroupName.nok("GroupName error: Characters . and _ can not precede each other.") 49 | 50 | if(contains("._")) 51 | return GroupName.nok("GroupName error: Characters . and _ can not precede each other.") 52 | 53 | if(!"""^[a-z][a-z0-9._]+[a-z]$""".toRegex().matches(this)) 54 | return GroupName.nok("GroupName error: Should be lowercase alphabetic separated by dots ('com.example').") 55 | 56 | return GroupName.ok(this) 57 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/InputOrThrow.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.KlutterException 25 | import dev.buijs.klutter.kore.common.Either 26 | import dev.buijs.klutter.kore.common.EitherNok 27 | import dev.buijs.klutter.kore.common.EitherOk 28 | 29 | fun Either.inputOrThrow( 30 | ok: (EitherOk) -> R, 31 | nok: (EitherNok) -> String 32 | ): R { 33 | return when(this) { 34 | is EitherOk -> 35 | ok.invoke(this) 36 | is EitherNok -> 37 | throw KlutterException(nok.invoke(this)) 38 | } 39 | } 40 | 41 | fun RootFolder.validRootFolderOrThrow() = inputOrThrow( 42 | ok = { 43 | it.data 44 | }, 45 | nok = { 46 | it.data 47 | } 48 | ) 49 | 50 | fun PluginName.validPluginNameOrThrow() = inputOrThrow( 51 | ok = { 52 | it.data 53 | }, 54 | nok = { 55 | it.data 56 | } 57 | ) 58 | 59 | fun GroupName.validGroupNameOrThrow()= inputOrThrow( 60 | ok = { 61 | it.data 62 | }, 63 | nok = { 64 | it.data 65 | } 66 | ) -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/InputPluginName.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.common.Either 25 | 26 | typealias PluginName = Either 27 | 28 | fun toPluginName(value: String) = value.toInput() 29 | 30 | /** 31 | * Validate a Klutter app name with the following constraints: 32 | * - All characters are lowercase 33 | * - All characters are alphabetic or 34 | * - numeric or 35 | * - '_' 36 | * - Should start with an alphabetic character 37 | */ 38 | private fun String.toInput(): PluginName { 39 | if(!"""^[a-z][a-z0-9_]+$""".toRegex().matches(this)) 40 | return PluginName.nok("PluginName error: Should only contain" + 41 | " lowercase alphabetic, numeric and or _ characters" + 42 | " and start with an alphabetic character ('my_plugin').") 43 | 44 | return PluginName.ok(this) 45 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/InputRootFolder.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.common.Either 25 | import java.io.File 26 | 27 | typealias RootFolder = Either 28 | 29 | fun toRootFolder(value: String) = value.toInput() 30 | 31 | private fun String.toInput(): RootFolder { 32 | val file = File(this) 33 | return if(!file.exists()) 34 | RootFolder.nok("Root folder does not exist: '$this'") 35 | else RootFolder.ok(file) 36 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/ProjectBuilderActions.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.KlutterException 25 | 26 | internal inline fun findProjectBuilderAction( 27 | options: ProjectBuilderOptions 28 | ): ProjectBuilderAction { 29 | return when(T::class.java) { 30 | RunFlutterCreate::class.java -> 31 | options.toRunFlutterAction() 32 | 33 | InitKlutter::class.java -> 34 | options.toInitKlutterAction() 35 | 36 | DownloadFlutter::class.java -> 37 | options.toDowloadFlutterTask() 38 | 39 | else -> throw KlutterException("Unknown ProjectBuilderAction: ${T::class.java}") 40 | } 41 | } 42 | 43 | internal sealed interface ProjectBuilderAction { 44 | fun doAction() 45 | } 46 | 47 | // Used for UT only! 48 | @Suppress("unused") 49 | private object GroovyHelper { 50 | @JvmStatic 51 | fun findProjectBuilderAction(options: ProjectBuilderOptions): ProjectBuilderAction = 52 | findProjectBuilderAction(options) 53 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/ProjectBuilderOptions.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.project.Config 25 | import dev.buijs.klutter.kore.project.FlutterDistributionFolderName 26 | import dev.buijs.klutter.kore.project.flutterDistribution 27 | 28 | data class ProjectBuilderOptions( 29 | /** 30 | * Path to the folder where to create the new project. 31 | */ 32 | val rootFolder: RootFolder, 33 | 34 | /** 35 | * Name of the plugin. 36 | */ 37 | val pluginName: PluginName, 38 | 39 | /** 40 | * Name of the plugin organisation. 41 | */ 42 | val groupName: GroupName, 43 | 44 | /** 45 | * Flutter SDK version. 46 | */ 47 | val flutterDistributionString: FlutterDistributionFolderName, 48 | 49 | /** 50 | * Custom configuration for tweaking project generation. 51 | */ 52 | val config: Config? = null, 53 | ) { 54 | val flutterFolder = flutterDistributionString.flutterDistribution 55 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/tasks/project/ProjectBuilderTask.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.KlutterTask 25 | 26 | /** 27 | * Task to generate a klutter plugin project. 28 | */ 29 | class ProjectBuilderTask(private val options: ProjectBuilderOptions) : KlutterTask { 30 | override fun run() { 31 | findProjectBuilderAction(options).doAction() 32 | findProjectBuilderAction(options).doAction() 33 | findProjectBuilderAction(options).doAction() 34 | } 35 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/templates/ProtobufExtensions.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.templates 2 | 3 | import dev.buijs.klutter.kore.KlutterPrinter 4 | 5 | class ProtobufExtensions( 6 | private val packageName: String, 7 | private val className: String, 8 | ): KlutterPrinter { 9 | 10 | override fun print(): String = """|package $packageName 11 | | 12 | |import kotlinx.serialization.ExperimentalSerializationApi 13 | |import kotlinx.serialization.decodeFromByteArray 14 | |import kotlinx.serialization.encodeToByteArray 15 | |import kotlinx.serialization.protobuf.ProtoBuf 16 | | 17 | |@OptIn(ExperimentalSerializationApi::class) 18 | |fun $className.encode${className}ToByteArray(): ByteArray = 19 | | ProtoBuf.encodeToByteArray(this) 20 | | 21 | |@OptIn(ExperimentalSerializationApi::class) 22 | |fun decodeByteArrayTo$className(byteArray: ByteArray): $className = 23 | | ProtoBuf.decodeFromByteArray(byteArray)""".trimMargin() 24 | 25 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/templates/Utilities.kt: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.templates 2 | 3 | import dev.buijs.klutter.kore.ast.* 4 | 5 | /** 6 | * Return the Dart className of an [AbstractType]. 7 | */ 8 | internal fun AbstractType.dartType() = when(this) { 9 | is StandardType -> this.dartType 10 | else -> this.className 11 | } 12 | 13 | /** 14 | * Append multiple lines. 15 | */ 16 | internal fun StringBuilder.appendLines(lines: Collection) { 17 | lines.forEach { line -> this.appendLine(line) } 18 | } 19 | 20 | internal fun StringBuilder.appendTemplate(template: String) { 21 | append(template.trimMargin()) 22 | } -------------------------------------------------------------------------------- /lib/kore/src/main/kotlin/dev/buijs/klutter/kore/templates/flutter/PackageLib.kt: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.templates.flutter 23 | 24 | import dev.buijs.klutter.kore.KlutterPrinter 25 | 26 | /** 27 | * Main package file which exports all generated widgets. 28 | */ 29 | class PackageLib( 30 | /** 31 | * Name of the package as published to pub. 32 | */ 33 | private val name: String, 34 | /** 35 | * List of all dart files to be exported. 36 | */ 37 | private val exports: List, 38 | ): KlutterPrinter { 39 | 40 | override fun print(): String = 41 | "library $name;\n" + exports.joinToString("\n") { "export '$it';" } 42 | 43 | } -------------------------------------------------------------------------------- /lib/kore/src/main/resources/protoc_plugin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buijs-dev/klutter/ba0297301880284906c2116d676f728ef0881b03/lib/kore/src/main/resources/protoc_plugin.exe -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/ExceptionSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore 2 | 3 | import spock.lang.Specification 4 | 5 | class ExceptionSpec extends Specification { 6 | 7 | def "Verify exception message"() { 8 | given: 9 | def exception = new KlutterException("BOOM!", null) 10 | 11 | expect: 12 | exception.message == "BOOM!" 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/ast/InterfacesSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.ast 2 | 3 | import spock.lang.Specification 4 | 5 | class InterfacesSpec extends Specification { 6 | 7 | def "toString returns classname"() { 8 | expect: 9 | new IntType().toString() == "IntType" 10 | } 11 | 12 | def "copy with fields returns correct name and fields"() { 13 | given: 14 | def type1 = new CustomType("Foo", "", [new TypeMember("count", new IntType())]) 15 | def type2 = new CustomType("Foo", "", [new TypeMember("doubleCount", new DoubleType())]) 16 | 17 | when: 18 | type1 = type1.copy(type2.members) 19 | 20 | then: 21 | type1.members == type2.members 22 | } 23 | 24 | def "nullable type copy with fields returns correct name and fields"() { 25 | given: 26 | def type1 = new NullableCustomType("Foo", "", [new TypeMember("count", new IntType())]) 27 | def type2 = new NullableCustomType("Foo", "", [new TypeMember("doubleCount", new DoubleType())]) 28 | 29 | when: 30 | type1 = type1.copy(type2.members) 31 | 32 | then: 33 | type1.members == type2.members 34 | } 35 | 36 | def "StandardType returns correct Kotlin and Dart type"() { 37 | expect: 38 | // L.O.L. yes use String because then 39 | // its clear if its a Dart or Kotlin type ;-) 40 | new StringType().kotlinType == "String" 41 | new StringType().dartType == "String" 42 | // Okay Int there you go: 43 | new IntType().kotlinType == "Int" 44 | new IntType().dartType == "int" 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/ast/StandardTypeMapSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.ast 2 | 3 | import dev.buijs.klutter.kore.KlutterException 4 | import spock.lang.Specification 5 | 6 | class StandardTypeMapSpec extends Specification { 7 | 8 | def "[StandardTypeMap] returns a valid Dart data type"() { 9 | expect: 10 | StandardTypeMap.toDartType("Double") == "double" 11 | StandardTypeMap.toDartType("Int") == "int" 12 | StandardTypeMap.toDartType("Boolean") == "bool" 13 | StandardTypeMap.toDartType("String") == "String" 14 | } 15 | 16 | def "[StandardTypeMap] returns a valid Kotlin data type"() { 17 | expect: 18 | StandardTypeMap.toKotlinType("double") == "Double" 19 | StandardTypeMap.toKotlinType("int") == "Int" 20 | StandardTypeMap.toKotlinType("bool") == "Boolean" 21 | StandardTypeMap.toKotlinType("String") == "String" 22 | } 23 | 24 | def "[StandardTypeMap] an exception is thrown when a Kotlin type does not exist"() { 25 | when: 26 | StandardTypeMap.toKotlinType("Stttttring!") 27 | 28 | then: 29 | KlutterException e = thrown() 30 | e.getMessage() == "No such type in KotlinDartMap: Stttttring!" 31 | } 32 | 33 | def "[StandardTypeMap] an exception is thrown when a Dart type does not exist"() { 34 | when: 35 | StandardTypeMap.toDartType("Stttttring!") 36 | 37 | then: 38 | KlutterException e = thrown() 39 | e.getMessage() == "No such type in KotlinDartMap: Stttttring!" 40 | } 41 | 42 | def "[StandardTypeMap] an exception is thrown when a Dart/Kotlin type does not exist"() { 43 | when: 44 | StandardTypeMap.toMap("Stttttring!") 45 | 46 | then: 47 | KlutterException e = thrown() 48 | e.getMessage() == "No such type in KotlinDartMap: Stttttring!" 49 | } 50 | 51 | def "[StandardTypeMap] null is returned when a Dart/Kotlin type does not exist"() { 52 | expect: 53 | StandardTypeMap.toMapOrNull("Stttttring!") == null 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/common/EitherSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.common 2 | 3 | import spock.lang.Specification 4 | 5 | class EitherSpec extends Specification { 6 | 7 | def "Verify Either.ok helper"(){ 8 | given: 9 | def ok = Either.ok("MyData") 10 | 11 | expect: 12 | ok instanceof EitherOk 13 | ok.data == "MyData" 14 | } 15 | 16 | def "Verify Either.nok helper"(){ 17 | given: 18 | def nok = Either.nok(99) 19 | 20 | expect: 21 | nok instanceof EitherNok 22 | nok.data == 99 23 | } 24 | } -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/common/StringUtilsSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.common 2 | 3 | 4 | import spock.lang.Specification 5 | 6 | class StringUtilsSpec extends Specification { 7 | 8 | def "[prefixIfNot] does nothing when prefix is present"() { 9 | given: 10 | def prefix = "MyPrefixString" 11 | 12 | expect: 13 | "MyPrefixString" == StringUtilsKt.prefixIfNot("MyPrefixString", prefix) 14 | } 15 | 16 | def "[prefixIfNot] adds prefix if not present"() { 17 | given: 18 | def prefix = "MyPrefix" 19 | 20 | expect: 21 | "MyPrefixString" == StringUtilsKt.prefixIfNot("String", prefix) 22 | } 23 | 24 | def "[toSnakeCase] converts camelcase correctly"() { 25 | expect: 26 | StringUtilsKt.toSnakeCase("MyCamelCas1eValue") == "my_camel_cas1e_value" 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/project/ConfigSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.project 2 | 3 | import spock.lang.Specification 4 | 5 | import java.nio.file.Files 6 | 7 | class ConfigSpec extends Specification { 8 | 9 | def "Verify config can be deserialized" () { 10 | given: 11 | def configFile = Files.createTempFile("", "").toFile() 12 | 13 | and: 14 | configFile.write(content) 15 | 16 | when: 17 | def config = ConfigKt.toConfigOrNull(configFile) 18 | 19 | then: 20 | config != null 21 | config.bomVersion == "2023.1.2-SNAPSHOT" 22 | config.dependencies.klutter == "2.0.0" 23 | config.dependencies.klutterUI == "1.0.0" 24 | config.dependencies.squint == "0.1.2" 25 | config.dependencies.embedded.size() == 1 26 | config.dependencies.embedded[0] == "org.jetbrains.kotlinx:kotlinx-datetime:0.4.0" 27 | 28 | where: 29 | content = '''bom-version: "2023.1.2-SNAPSHOT" 30 | dependencies: 31 | klutter: "2.0.0" 32 | klutter_ui: "1.0.0" 33 | squint_json: "0.1.2" 34 | embedded: 35 | - "org.jetbrains.kotlinx:kotlinx-datetime:0.4.0"''' 36 | } 37 | 38 | def "When config File does not exist then null is returned" () { 39 | expect: 40 | ConfigKt.toConfigOrNull(new File("doesNotExist")) == null 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/DummyExec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.tasks 2 | 3 | class DummyExec extends Executor { 4 | @Override 5 | String execute(File file, Long l, String s, Map m) { 6 | "" 7 | } 8 | } -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/GetDartProtocExeTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks 23 | 24 | 25 | import spock.lang.Specification 26 | 27 | class GetDartProtocExeTaskSpec extends Specification { 28 | 29 | def "Verify protoc_plugin executable can be loaded from resources"() { 30 | expect: 31 | new GetDartProtocExeTask() != null 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/codegen/DartFormatTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.codegen 23 | 24 | import dev.buijs.klutter.kore.tasks.DummyExec 25 | import dev.buijs.klutter.kore.tasks.ExecutorKt 26 | import dev.buijs.klutter.kore.tasks.codegen.DartFormatTask 27 | import spock.lang.Specification 28 | 29 | import java.nio.file.Files 30 | 31 | class DartFormatTaskSpec extends Specification { 32 | 33 | def "Verify constructor"(){ 34 | given: 35 | ExecutorKt.executor = new DummyExec() 36 | 37 | and: 38 | def file = Files.createTempDirectory("").toFile() 39 | 40 | expect: 41 | new DartFormatTask(file, "3.0.5.macos.arm64", {}).run() 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/codegen/GenerateProtoExtensionsTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.tasks.codegen 2 | 3 | import spock.lang.Specification 4 | 5 | import java.nio.file.Files 6 | 7 | class GenerateProtoExtensionsTaskSpec extends Specification { 8 | 9 | def "Verify protobuf extension methods are generated correctly"() { 10 | 11 | given: 12 | def source = Files.createTempDirectory("").toFile() 13 | def kotlin = source.toPath().resolve("com/example/my_plugin/platform").toFile() 14 | kotlin.mkdirs() 15 | 16 | when: 17 | new GenerateProtoExtensionsTask(source, ["com.example.my_plugin.platform.MyGreeting"]).run() 18 | 19 | then: 20 | def generatedFile = kotlin.toPath().resolve("${GenerateProtoExtensionsTaskKt.protoGenMarker}MyGreeting.kt").toFile() 21 | generatedFile.exists() 22 | println(generatedFile.text) 23 | generatedFile.text == """package com.example.my_plugin.platform 24 | 25 | import kotlinx.serialization.ExperimentalSerializationApi 26 | import kotlinx.serialization.decodeFromByteArray 27 | import kotlinx.serialization.encodeToByteArray 28 | import kotlinx.serialization.protobuf.ProtoBuf 29 | 30 | @OptIn(ExperimentalSerializationApi::class) 31 | fun MyGreeting.encodeMyGreetingToByteArray(): ByteArray = 32 | ProtoBuf.encodeToByteArray(this) 33 | 34 | @OptIn(ExperimentalSerializationApi::class) 35 | fun decodeByteArrayToMyGreeting(byteArray: ByteArray): MyGreeting = 36 | ProtoBuf.decodeFromByteArray(byteArray)""" 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/project/Exeggutor.groovy: -------------------------------------------------------------------------------- 1 | package dev.buijs.klutter.kore.tasks.project 2 | 3 | import dev.buijs.klutter.kore.tasks.Executor 4 | 5 | class Exeggutor extends Executor { 6 | 7 | /** 8 | * Map of expected CLI executions. 9 | * 10 | * Key: String absolute path where command is to be executed. 11 | * Value: List commands to be executed. 12 | */ 13 | private def expectations = new HashMap>() 14 | 15 | /** 16 | * Execute action when an expectation is met. 17 | */ 18 | private def actionsAfterExpectation = new HashMap() 19 | 20 | @Override 21 | String execute(File runFrom, Long timeout, String command, Map env) { 22 | if(expectations.containsKey(runFrom.absolutePath)) { 23 | if(expectations[runFrom.absolutePath].contains(command)) { 24 | def actionOrNull = actionsAfterExpectation[command] 25 | if(actionOrNull != null) 26 | actionOrNull.call() 27 | return "" 28 | } 29 | } 30 | 31 | throw new RuntimeException("CLI execution failure: $command - $runFrom.absolutePath") 32 | } 33 | 34 | def putExpectation(String runFrom, String command) { 35 | if(!expectations.containsKey(runFrom)) { 36 | expectations.put(runFrom, [command]) 37 | } else { 38 | expectations.get(runFrom).add(command) 39 | } 40 | } 41 | 42 | def putExpectationWithAction(String runFrom, String command, Closure action) { 43 | if(!expectations.containsKey(runFrom)) { 44 | expectations.put(runFrom, [command]) 45 | } else { 46 | expectations.get(runFrom).add(command) 47 | } 48 | 49 | actionsAfterExpectation.put(command, action) 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/project/InputGroupNameSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.common.EitherNok 25 | import dev.buijs.klutter.kore.common.EitherOk 26 | import dev.buijs.klutter.kore.tasks.project.InputGroupNameKt 27 | import spock.lang.Specification 28 | 29 | class InputGroupNameSpec extends Specification { 30 | 31 | def "Verify valid group names"() { 32 | expect: 33 | with(InputGroupNameKt.toGroupName(name)) { 34 | it instanceof EitherOk 35 | (it as EitherOk).data == name 36 | } 37 | where: 38 | name << [ 39 | "com.example", 40 | "com.example.app", 41 | "awesome.group_1.name", 42 | "awesome.group1_1.name" 43 | ] 44 | } 45 | 46 | def "Verify invalid group names"() { 47 | expect: 48 | with(InputGroupNameKt.toGroupName(name)) { 49 | it instanceof EitherNok 50 | (it as EitherNok).data == message 51 | } 52 | 53 | where: 54 | name | message 55 | "1.dev" | "GroupName error: Should be lowercase alphabetic separated by dots ('com.example')." 56 | "_.my.group" | "GroupName error: Characters . and _ can not precede each other." 57 | "com_.group" | "GroupName error: Characters . and _ can not precede each other." 58 | "groupie" | "GroupName error: Should contain at least 2 parts ('com.example')." 59 | "group._" | "GroupName error: Characters . and _ can not precede each other." 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/project/InputPluginNameSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.common.EitherNok 25 | import dev.buijs.klutter.kore.common.EitherOk 26 | import dev.buijs.klutter.kore.tasks.project.InputPluginNameKt 27 | import spock.lang.Specification 28 | 29 | class InputPluginNameSpec extends Specification { 30 | 31 | def "Verify valid plugin names"() { 32 | expect: 33 | with(InputPluginNameKt.toPluginName(name)) { 34 | it instanceof EitherOk 35 | (it as EitherOk).data == name 36 | } 37 | where: 38 | name << [ 39 | "plugin", 40 | "my_plugin", 41 | "my_awesome_plugin_2", 42 | "myawesome2plugins" 43 | ] 44 | } 45 | 46 | def "Verify invalid plugin names"() { 47 | expect: 48 | with(InputPluginNameKt.toPluginName(name)) { 49 | it instanceof EitherNok 50 | (it as EitherNok).data == "PluginName error: Should only contain" + 51 | " lowercase alphabetic, numeric and or _ characters" + 52 | " and start with an alphabetic character ('my_plugin')." 53 | } 54 | where: 55 | name << [ 56 | "1plugin", // can not start with a number 57 | "_my_plugin", // can not start with an underscore 58 | "my_awesome_plugin!!!", // can not contain: !! 59 | "MYAWESOMEPLUGIN" // can not be uppercase 60 | ] 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/project/InputRootFolderSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2023 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.common.EitherNok 25 | import dev.buijs.klutter.kore.common.EitherOk 26 | import dev.buijs.klutter.kore.tasks.project.InputRootFolderKt 27 | import spock.lang.Specification 28 | 29 | import java.nio.file.Files 30 | 31 | class InputRootFolderSpec extends Specification { 32 | 33 | def "If folder does not exist then toRootFolder returns EitherNok"() { 34 | expect: 35 | with(InputRootFolderKt.toRootFolder("doesNotExist")) { 36 | it instanceof EitherNok 37 | (it as EitherNok).data == "Root folder does not exist: 'doesNotExist'" 38 | } 39 | } 40 | 41 | def "If folder exists then toRootFolder returns EitherOk"() { 42 | given: 43 | def folder = Files.createTempDirectory("").toFile() 44 | 45 | expect: 46 | with(InputRootFolderKt.toRootFolder(folder.absolutePath)) { 47 | it instanceof EitherOk 48 | (it as EitherOk).data == folder 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/kore/src/test/groovy/dev/buijs/klutter/kore/tasks/project/ProjectBuilderActionsSpec.groovy: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 - 2022 Buijs Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | * 21 | */ 22 | package dev.buijs.klutter.kore.tasks.project 23 | 24 | import dev.buijs.klutter.kore.KlutterException 25 | import dev.buijs.klutter.kore.common.Either 26 | import dev.buijs.klutter.kore.tasks.project.ProjectBuilderOptions 27 | import spock.lang.Specification 28 | 29 | import static dev.buijs.klutter.kore.tasks.project.GroovyHelper.findProjectBuilderAction 30 | 31 | class ProjectBuilderActionsSpec extends Specification { 32 | 33 | def "Verify a KlutterException is thrown if no ProjectBuilderAction is found"(){ 34 | when: 35 | findProjectBuilderAction( 36 | new ProjectBuilderOptions( 37 | Either.ok(new File("")), 38 | Either.ok(""), 39 | Either.ok(""), 40 | "3.0.5.macos.arm64", 41 | null)) 42 | 43 | then: 44 | KlutterException e = thrown() 45 | e.message == "Unknown ProjectBuilderAction: interface dev.buijs.klutter.kore.tasks.project.ProjectBuilderAction" 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Project modules 2 | include(":lib:annotations") 3 | include(":lib:bill-of-materials") 4 | include(":lib:compiler") 5 | include(":lib:gradle") 6 | include(":lib:jetbrains") 7 | include(":lib:kompose") 8 | include(":lib:kore") 9 | // Internal Testing library 10 | include(":lib-test") 11 | // Internal build properties 12 | includeBuild("lib-build") -------------------------------------------------------------------------------- /tools/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | _develop.properties 3 | _release.properties 4 | ./publish_plugins-release.sh 5 | /_develop.properties 6 | /_publish.properties 7 | /_release.properties 8 | /publish_all_release.sh 9 | /gradle.properties 10 | /gradlew 11 | /gradlew.bat 12 | /gradle/wrapper/gradle-wrapper.properties 13 | /publish_gradle_plugin_release.sh 14 | -------------------------------------------------------------------------------- /tools/build_publish_kore.compiler.gradle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter modules > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | ./gradlew clean build -p "lib/kore" 17 | ./gradlew clean build -p "lib/compiler" 18 | ./gradlew clean build -p "lib/gradle" 19 | ./gradlew publishToMavenLocal -p "lib/kore" 20 | ./gradlew publishToMavenLocal -p "lib/compiler" 21 | ./gradlew publishToMavenLocal -p "lib/gradle" 22 | -------------------------------------------------------------------------------- /tools/publish_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter modules > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | ./gradlew publishToMavenLocal -p "lib/annotations" 17 | ./gradlew publishToMavenLocal -p "lib/bill-of-materials" 18 | ./gradlew publishToMavenLocal -p "lib/compiler" 19 | ./gradlew publishToMavenLocal -p "lib/gradle" 20 | ./gradlew publishToMavenLocal -p "lib/kompose" 21 | ./gradlew publishToMavenLocal -p "lib/kore" -------------------------------------------------------------------------------- /tools/publish_annotations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter Annotations modules > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | echo "\0/ Klutter: step: build annotations modules" 17 | echo "------------------" 18 | ./gradlew clean -p "lib/annotations" 19 | ./gradlew build -p "lib/annotations" 20 | 21 | echo "\0/ Klutter: step: publish annotations modules" 22 | echo "------------------" 23 | ./gradlew publish -p "lib/annotations" 24 | ./gradlew publishToMavenLocal -p "lib/annotations" -------------------------------------------------------------------------------- /tools/publish_bom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter bill-of-materials modules > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | echo "\0/ Klutter: step: build bill-of-materials modules" 17 | echo "------------------" 18 | ./gradlew clean -p "lib/bill-of-materials" 19 | ./gradlew build -p "lib/bill-of-materials" 20 | 21 | echo "\0/ Klutter: step: publish bill-of-materials modules" 22 | echo "------------------" 23 | #./gradlew publish -p "lib/bill-of-materials" 24 | ./gradlew publishToMavenLocal -p "lib/bill-of-materials" -------------------------------------------------------------------------------- /tools/publish_compiler.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter compiler modules > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | echo "\0/ Klutter: step: build compiler modules" 17 | echo "------------------" 18 | ./gradlew clean -p "lib/compiler" 19 | ./gradlew build -p "lib/compiler" 20 | 21 | echo "\0/ Klutter: step: publish compiler modules" 22 | echo "------------------" 23 | #./gradlew publish -p "lib/compiler" 24 | ./gradlew publishToMavenLocal -p "lib/compiler" -------------------------------------------------------------------------------- /tools/publish_gradle_plugin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter Gradle Plugin > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | echo "\0/ Klutter: step: build gradle modules" 17 | echo "------------------" 18 | ./gradlew clean -p "lib/gradle" 19 | ./gradlew build -p "lib/gradle" 20 | 21 | echo "\0/ Klutter: step: publish gradle modules" 22 | echo "------------------" 23 | #./gradlew publish -p "lib/gradle" 24 | ./gradlew publishToMavenLocal -p "lib/gradle" -------------------------------------------------------------------------------- /tools/publish_kompose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter Kompose modules > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | echo "\0/ Klutter: step: build kompose modules" 17 | echo "------------------" 18 | ./gradlew clean -p "lib/kompose" 19 | ./gradlew build -p "lib/kompose" 20 | 21 | echo "\0/ Klutter: step: publish kompose modules" 22 | echo "------------------" 23 | ./gradlew publish -p "lib/kompose" 24 | ./gradlew publishToMavenLocal -p "lib/kompose" -------------------------------------------------------------------------------- /tools/publish_kore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #stop script on failure 3 | set -e 4 | 5 | cd ".." 6 | 7 | echo " ____________ 8 | < Publishing Klutter Kore modules > 9 | ------------ 10 | \ ^__^ 11 | \ (oo)\_______ 12 | (__)\ )\/\ 13 | ||----w | 14 | || ||" 15 | 16 | echo "\0/ Klutter: step: build kore modules" 17 | echo "------------------" 18 | ./gradlew clean -p "lib/kore" 19 | ./gradlew build -p "lib/kore" 20 | 21 | echo "\0/ Klutter: step: publish core modules" 22 | echo "------------------" 23 | #./gradlew publish -p "lib/kore" 24 | ./gradlew publishToMavenLocal -p "lib/kore" --------------------------------------------------------------------------------