-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
338 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: ci | ||
on: [ push, pull_request ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
cache: 'gradle' | ||
|
||
- name: Gradle build | ||
run: ./gradlew build --no-daemon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# KIK | ||
|
||
[![ci](https://github.com/erwin-kok/kik/actions/workflows/ci.yaml/badge.svg)](https://github.com/erwin-kok/kik/actions/workflows/ci.yaml) | ||
[![Kotlin](https://img.shields.io/badge/kotlin-2.1.0-blue.svg?logo=kotlin)](http://kotlinlang.org) | ||
[![License](https://img.shields.io/github/license/erwin-kok/kik.svg)](https://github.com/erwin-kok/kik/blob/master/LICENSE) | ||
|
||
Experimental |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,26 @@ | ||
[versions] | ||
kotlin = "2.0.21" | ||
auto-service = "1.1.1" | ||
auto-service-ksp = "1.2.0" | ||
kotlin = "2.1.0" | ||
kotlin-compile-testing = "0.7.0" | ||
|
||
# Plugins | ||
compatibility-plugin = "0.16.3" | ||
ksp-plugin = "2.1.0-1.0.29" | ||
versions-plugin = "0.51.0" | ||
|
||
[libraries] | ||
kotlin-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" } | ||
kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } | ||
|
||
auto-service = { module = "com.google.auto.service:auto-service", version.ref = "auto-service" } | ||
auto-service-annotations = { module = "com.google.auto.service:auto-service-annotations", version.ref = "auto-service" } | ||
auto-service-ksp = { module = "dev.zacsweers.autoservice:auto-service-ksp", version.ref = "auto-service-ksp" } | ||
kotlin-compile-testing = { module = "dev.zacsweers.kctfork:core", version.ref = "kotlin-compile-testing" } | ||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } | ||
|
||
[plugins] | ||
build-versions = { id = "com.github.ben-manes.versions", version.ref = "versions-plugin" } | ||
compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "compatibility-plugin" } | ||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp-plugin" } | ||
versions = { id = "com.github.ben-manes.versions", version.ref = "versions-plugin" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
idea | ||
kotlin("jvm") version "2.1.0" | ||
alias(libs.plugins.ksp) | ||
alias(libs.plugins.compatibility) | ||
} | ||
|
||
group = "org.erwinkok.kik" | ||
version = "0.1.0" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib")) | ||
implementation(gradleApi()) | ||
implementation(libs.kotlin.compiler.embeddable) | ||
implementation(libs.auto.service) | ||
implementation(libs.auto.service.annotations) | ||
ksp(libs.auto.service.ksp) | ||
|
||
testImplementation(libs.kotlin.compile.testing) | ||
testImplementation(libs.kotlin.test) | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_17) | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
sourceCompatibility = JavaVersion.VERSION_17.toString() | ||
targetCompatibility = JavaVersion.VERSION_17.toString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
|
||
versionCatalogs { | ||
create("libs") { | ||
if (file("../gradle/libs.versions.toml").exists()) { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "kik-compiler-plugin" |
47 changes: 47 additions & 0 deletions
47
kik-compiler-plugin/src/main/kotlin/org/erwinkok/kik/compiler/KikCommandLineProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@file:OptIn(ExperimentalCompilerApi::class) | ||
|
||
package org.erwinkok.kik.compiler | ||
|
||
import com.google.auto.service.AutoService | ||
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption | ||
import org.jetbrains.kotlin.compiler.plugin.CliOption | ||
import org.jetbrains.kotlin.compiler.plugin.CliOptionProcessingException | ||
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor | ||
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
import org.jetbrains.kotlin.config.CompilerConfigurationKey | ||
import kotlin.text.toBoolean | ||
|
||
@AutoService(CommandLineProcessor::class) | ||
class KikCommandLineProcessor : CommandLineProcessor { | ||
companion object { | ||
internal val KEY_ENABLED = CompilerConfigurationKey<Boolean>("Enable/disable the kik compiler plugin on the given compilation") | ||
internal val KEY_DEBUG = CompilerConfigurationKey<Boolean>("Enable/disable debug logging on the given compilation") | ||
|
||
val ENABLED_OPTION = | ||
CliOption( | ||
optionName = "enabled", | ||
valueDescription = "<true | false>", | ||
description = KEY_ENABLED.toString(), | ||
required = true, | ||
allowMultipleOccurrences = false, | ||
) | ||
val DEBUG_OPTION = | ||
CliOption( | ||
optionName = "debug", | ||
valueDescription = "<true | false>", | ||
description = KEY_DEBUG.toString(), | ||
required = false, | ||
allowMultipleOccurrences = false, | ||
) | ||
} | ||
|
||
override val pluginId = "org.erwinkok.kik.kik-compiler-plugin" | ||
override val pluginOptions = listOf(ENABLED_OPTION, DEBUG_OPTION) | ||
|
||
override fun processOption(option: AbstractCliOption, value: String, configuration: CompilerConfiguration) = when (option) { | ||
ENABLED_OPTION -> configuration.put(KEY_ENABLED, value.toBoolean()) | ||
DEBUG_OPTION -> configuration.put(KEY_DEBUG, value.toBoolean()) | ||
else -> throw CliOptionProcessingException("Unknown option: ${option.optionName}") | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
kik-compiler-plugin/src/main/kotlin/org/erwinkok/kik/compiler/KikComponentRegistrar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@file:OptIn(ExperimentalCompilerApi::class) | ||
|
||
package org.erwinkok.kik.compiler | ||
|
||
import com.google.auto.service.AutoService | ||
import org.erwinkok.kik.compiler.KikCommandLineProcessor.Companion.KEY_ENABLED | ||
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar | ||
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar.ExtensionStorage | ||
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
|
||
@AutoService(CompilerPluginRegistrar::class) | ||
class SerializationComponentRegistrar : CompilerPluginRegistrar() { | ||
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) { | ||
if (configuration[KEY_ENABLED] == false) { | ||
return | ||
} | ||
} | ||
|
||
override val supportsK2: Boolean | ||
get() = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
|
||
versionCatalogs { | ||
create("libs") { | ||
if (file("../gradle/libs.versions.toml").exists()) { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "kik-gradle-plugin" | ||
|
||
include(":typesystem") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
idea | ||
kotlin("jvm") version "2.1.0" | ||
id("java-gradle-plugin") | ||
} | ||
|
||
group = "org.erwinkok.kik.gradleplugin" | ||
version = "0.1.0" | ||
|
||
gradlePlugin { | ||
website.set("https://github.com/erwin-kok/kik") | ||
vcsUrl.set("https://github.com/erwin-kok/kik") | ||
plugins { | ||
create("kikCompilerPlugin") { | ||
id = "org.erwinkok.kik.compiler-plugin" | ||
implementationClass = "org.erwinkok.kik.compiler.gradleplugin.KikCompilerGradlePlugin" | ||
displayName = "kik-compiler Gradle Plugin" | ||
description = displayName | ||
tags.set(listOf("http", "kotlin", "kotlin-mpp", "k8s")) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib")) | ||
implementation(gradleApi()) | ||
} | ||
|
||
dependencies { | ||
add("compileOnly", kotlin("gradle-plugin")) | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_17) | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
sourceCompatibility = JavaVersion.VERSION_17.toString() | ||
targetCompatibility = JavaVersion.VERSION_17.toString() | ||
} |
12 changes: 12 additions & 0 deletions
12
.../src/main/kotlin/org/erwinkok/kik/compiler/gradleplugin/KikCompilerGradleConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.erwinkok.kik.compiler.gradleplugin | ||
|
||
enum class ErrorCheckingMode { | ||
NONE, | ||
WARNING, | ||
ERROR, | ||
} | ||
|
||
open class KikCompilerGradleConfiguration { | ||
var generateQualifiedTypeName: Boolean = false | ||
var errorCheckingMode: ErrorCheckingMode = ErrorCheckingMode.ERROR | ||
} |
15 changes: 15 additions & 0 deletions
15
...esystem/src/main/kotlin/org/erwinkok/kik/compiler/gradleplugin/KikCompilerGradlePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2024. Erwin Kok. Apache License. See LICENSE file for more details. | ||
package org.erwinkok.kik.compiler.gradleplugin | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import kotlin.jvm.java | ||
|
||
class KikCompilerGradlePlugin : Plugin<Project> { | ||
override fun apply(project: Project) { | ||
with(project) { | ||
extensions.create("kikCompiler", KikCompilerGradleConfiguration::class.java) | ||
pluginManager.apply(KikCompilerSubPlugin::class.java) | ||
} | ||
} | ||
} |
Oops, something went wrong.