Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/kotlinx-rpc.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .puppeteerrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {join} = require('path');

const isCI = process.env.TEAMCITY_VERSION
const isCI = process.env.TEAMCITY_VERSION || process.env.GITHUB_ACTIONS;

if (isCI) {
/**
Expand Down
2 changes: 1 addition & 1 deletion bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import util.KOTLINX_RPC_PREFIX
import util.isPublicModule
import util.other.isPublicModule

plugins {
`java-platform`
Expand Down
75 changes: 2 additions & 73 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,16 @@
*/

import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import util.asDokkaVersion
import util.configureNpm
import util.configureProjectReport
import util.registerDumpPlatformTableTask
import util.registerChangelogTask
import util.libs
import util.registerVerifyPlatformTableTask
import java.time.Year

plugins {
alias(libs.plugins.serialization) apply false
alias(libs.plugins.kotlinx.rpc) apply false
alias(libs.plugins.atomicfu) apply false
alias(libs.plugins.conventions.kover)
alias(libs.plugins.conventions.gradle.doctor)
alias(libs.plugins.dokka)
alias(libs.plugins.atomicfu)
id("build-util")
alias(libs.plugins.conventions.root)
}

dokka {
val libDokkaVersion = libs.versions.kotlinx.rpc.get().asDokkaVersion()

moduleVersion.set(libDokkaVersion)

val pagesDirectory = layout.projectDirectory
.dir("docs")
.dir("pages")

val dokkaVersionsDirectory = pagesDirectory
.dir("api")
.asFile

val templatesDirectory = pagesDirectory
.dir("templates")

pluginsConfiguration {
html {
customAssets.from(
"docs/pages/assets/logo-icon.svg",
"docs/pages/assets/homepage.svg", // Doesn't work due to https://github.com/Kotlin/dokka/issues/4007
)

footerMessage = "© ${Year.now()} JetBrains s.r.o and contributors. Apache License 2.0"
homepageLink = "https://kotlin.github.io/kotlinx-rpc/get-started.html"

// replace with homepage.svg once the mentioned issue is resolved
templatesDir.set(templatesDirectory)
}

// enable versioning for stable
// versioning {
// version = libDokkaVersion
// olderVersionsDir = dokkaVersionsDirectory
// }
}

dokkaPublications.html {
outputDirectory = dokkaVersionsDirectory
}

tasks.clean {
delete(dokkaVersionsDirectory)
}

dokkaGeneratorIsolation = ProcessIsolation {
// Configures heap size, use if start to fail with OOM on CI
// maxHeapSize = "4g"
}
}

dependencies {
dokkaPlugin(libs.dokka.rpc.plugin)
}

configureProjectReport()
configureNpm()

registerDumpPlatformTableTask()
registerVerifyPlatformTableTask()
registerChangelogTask()

val kotlinVersion = rootProject.libs.versions.kotlin.lang.get()
val kotlinCompiler = rootProject.libs.versions.kotlin.compiler.get()

Expand Down
3 changes: 1 addition & 2 deletions compiler-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import util.whenForIde

plugins {
alias(libs.plugins.conventions.gradle.doctor)
id("build-util")
}

val rpcVersion: String = libs.versions.kotlinx.rpc.get()
Expand All @@ -30,5 +29,5 @@ println(
)

whenForIde {
println("For-ide project mode enabled")
println("[Compiler Plugin] For-ide project mode enabled")
}
51 changes: 2 additions & 49 deletions compiler-plugin/compiler-plugin-k2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,23 @@
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
import util.enableContextParameters
import util.otherwise
import util.whenForIde
import util.whenKotlinCompilerIsAtLeast

plugins {
alias(libs.plugins.conventions.jvm)
alias(libs.plugins.compiler.specific.module)
alias(libs.plugins.shadow.jar)
}

/*
This is a hack to solve the next problem:

There is PsiElement class that is used in compiler and plugin.

If we use kotlin-compiler-embeddable.jar to compile the module,
PsiElement is org.jetbrains.kotlin.com.jetbrains.intellij.PsiElement.
And it works ok in the user projects!

But.

If we run tests, which use kotlin-compiler.jar, we run into ClassNotFoundException.
Because the class it has in th classpath is com.jetbrains.intellij.PsiElement

- Alright, we can use kotlin-compiler.jar to compile the plugin.
- No, because the same error now will occur in the user projects,
but it is com.jetbrains.intellij.PsiElement that is not found.

- Ok, we can use kotlin-compiler-embeddable.jar to compile tests.
- Then we ran into java.lang.VerifyError: Bad type on operand stack, which I have no idea how to fix.

This solution replaces org.jetbrains.kotlin.com.jetbrains.intellij.PsiElement usages in plugin
with com.jetbrains.intellij.PsiElement only for the tests, fixing both use cases.
It is basically a reverse engineering of what Kotlin does for the embedded jar.
*/
val shadowJar = tasks.named<ShadowJar>("shadowJar") {
configurations = listOf(project.configurations.compileClasspath.get())
relocate("org.jetbrains.kotlin.com.intellij.psi", "com.intellij.psi")

exclude("javaslang/**")
exclude("kotlin/**")
exclude("messages/**")
exclude("misc/**")
exclude("org/**")

archiveFileName.set("plugin-k2-for-tests.jar")

/**
* Same problem as above, but in IDE
*/
tasks.jar {
// important for IDEA plugin
whenForIde {
archiveClassifier.set("for-ide")
} otherwise {
archiveClassifier.set("tests")
}
}

tasks.jar {
finalizedBy(shadowJar)
}

kotlin {
explicitApi = ExplicitApiMode.Disabled

Expand Down
1 change: 0 additions & 1 deletion compiler-plugin/gradle.properties

This file was deleted.

40 changes: 40 additions & 0 deletions compiler-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#

kotlin.code.style=official

kotlin.native.ignoreDisabledTargets=true

kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
kotlin.daemon.useFallbackStrategy=false

org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.workers.max=8
org.gradle.caching=true
org.gradle.configuration-cache=true

org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
kotlinx.rpc.plugin.internalDevelopment=true

# uncomment to debug compilation process
#kotlin.compiler.execution.strategy=in-process

# Uncomment to skip attempts to publish Develocity build scans
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipBuildScans=true

# Uncomment to skip adding git tags to Develocity build scan
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipGitTags=true

# Uncomment to sync IDEA when working with Kotlin master builds
#kotlinx.rpc.kotlinMasterBuild=true

# set to true when building IDE compiler plugin artifacts
kotlinx.rpc.forIdeBuild=false
5 changes: 1 addition & 4 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import util.applyAtomicfuPlugin

plugins {
alias(libs.plugins.conventions.kmp)
alias(libs.plugins.kotlinx.rpc)
alias(libs.plugins.atomicfu)
}

applyAtomicfuPlugin()

kotlin {
sourceSets {
commonMain {
Expand Down
13 changes: 0 additions & 13 deletions docs/Multiple-Kotlin-Versions-Support.md

This file was deleted.

14 changes: 5 additions & 9 deletions dokka-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@

plugins {
alias(libs.plugins.conventions.gradle.doctor)
id("build-util")
alias(libs.plugins.kotlin.jvm)
}

val rpcVersion: String = libs.versions.kotlinx.rpc.get()
val kotlinLangVersion = libs.versions.kotlin.lang.get()

group = "org.jetbrains.kotlinx"
version = rpcVersion
version = libs.versions.kotlinx.rpc.get()

println("[Dokka Plugin] kotlinx.rpc project version: $version, Kotlin version: $kotlinLangVersion")
println("[Dokka Plugin] kotlinx.rpc project version: $version, Kotlin version: ${libs.versions.kotlin.lang.get()}")

kotlin {
jvmToolchain(8)
Expand All @@ -26,7 +22,7 @@ dependencies {

testImplementation(kotlin("test"))
testImplementation(libs.dokka.base)
testImplementation("org.jetbrains.dokka:dokka-test-api:${libs.versions.dokka.get()}")
testImplementation("org.jetbrains.dokka:dokka-base-test-utils:${libs.versions.dokka.get()}")
testImplementation("org.jetbrains.dokka:analysis-kotlin-symbols:${libs.versions.dokka.get()}")
testImplementation(libs.dokka.test.api)
testImplementation(libs.dokka.base.test.utils)
testImplementation(libs.dokka.analysis.kotlin.symbols)
}
40 changes: 40 additions & 0 deletions dokka-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#

kotlin.code.style=official

kotlin.native.ignoreDisabledTargets=true

kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
kotlin.daemon.useFallbackStrategy=false

org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.workers.max=8
org.gradle.caching=true
org.gradle.configuration-cache=true

org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
kotlinx.rpc.plugin.internalDevelopment=true

# uncomment to debug compilation process
#kotlin.compiler.execution.strategy=in-process

# Uncomment to skip attempts to publish Develocity build scans
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipBuildScans=true

# Uncomment to skip adding git tags to Develocity build scan
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipGitTags=true

# Uncomment to sync IDEA when working with Kotlin master builds
#kotlinx.rpc.kotlinMasterBuild=true

# set to true when building IDE compiler plugin artifacts
kotlinx.rpc.forIdeBuild=false
2 changes: 1 addition & 1 deletion gradle-conventions-settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

plugins {
alias(libs.plugins.gradle.kotlin.dsl)
`kotlin-dsl`
}

dependencies {
Expand Down
6 changes: 3 additions & 3 deletions gradle-conventions-settings/develocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*/

plugins {
alias(libs.plugins.gradle.kotlin.dsl)
`kotlin-dsl`
}

dependencies {
implementation("com.gradle:develocity-gradle-plugin:3.17")
implementation("com.gradle:common-custom-user-data-gradle-plugin:2.2.1")
implementation(libs.develocity)
implementation(libs.common.custom.user.data)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ develocity {
server.set(DEVELOCITY_SERVER)

buildScan {
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = loadAgreement()

uploadInBackground.set(!isCIRun)

// obfuscate NIC since we don't want to expose user real IP (will be relevant without VPN)
Expand All @@ -35,7 +38,7 @@ develocity {
.getOrElse("false")
.toBooleanStrict()

publishing.onlyIf { !skipBuildScans }
publishing.onlyIf { termsOfUseAgree.get() == "yes" && !skipBuildScans }
}
}

Expand Down
Loading
Loading