Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for the Kotlin JS plugin #271

Merged

Conversation

andrewparmet
Copy link
Collaborator

@andrewparmet andrewparmet commented May 28, 2024

Reworks Kotlin JS and multiplatform support to run the protoc plugin one time per target, placing generated code in a separate directory per target.

Fixes #208.

configureProtokt(this, null, disableJava) {
"$rootDir/protokt-codegen/build/install/$CODEGEN_NAME/bin/$CODEGEN_NAME"
}
configureProtokt(this, null, disableJava, "$rootDir/protokt-codegen/build/install/$CODEGEN_NAME/bin/$CODEGEN_NAME")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for deferred evaluation anymore and this was causing a problem in the plugin integration test as it tried to create the new _codegen_ configuration once per target.

extensions/protokt-extensions-lite/build.gradle.kts Outdated Show resolved Hide resolved
@@ -73,6 +72,7 @@ kotlin {
all {
compilations.all {
kotlinOptions {
allWarningsAsErrors = false
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suppression of OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE itself throws a compilation warning that can't (as far as I can tell) be excluded with a compiler arg. Gets a shrug from me.

@@ -87,13 +87,6 @@ tasks.named<Test>("jvmTest") {
useJUnitPlatform()
}

// awkward that we have to apply the plugin after source sets are configured
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See code comment about determining Kotlin targets without afterEvaluate.

@@ -63,14 +63,12 @@ private fun main(`in`: InputStream, out: OutputStream) {

val grpcKotlinFiles = generateGrpcKotlinStubs(params, req)

if (files.isNotEmpty() || grpcKotlinFiles.isNotEmpty()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you generate nothing and the input has a file that uses proto3 optional, protoc fails since you didn't reply that you support the feature. We just didn't happen to trigger this. IIRC I added this check to handle an issue we had when trying to return no files, but clearly that's not a problem anymore.

addAnnotation(
AnnotationSpec.builder(Suppress::class).apply {
addMember("DEPRECATION".embed())
// Suppresses a failure due to usage of @JvmStatic in common code. It seems prudent to add this
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only actually triggered a problem in the multiplatform integration test project. So strange.

@@ -431,15 +430,14 @@ private class ServiceGenerator(
}

private fun <T> pivotPlugin(jvm: T, js: T) =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have the concept of a generation target I want to clean this up, but it's complex logic and doesn't have to be cleaned up yet.

jsProcessResources?.excludeDuplicates()
}

// TODO: figure out how to get rid of this?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't quite figure out what's going wrong here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - this was already needed, I just forgot about it.

@@ -139,8 +179,11 @@ private fun Project.linkGenerateProtoTasksAndIncludeGeneratedSource(sourceSetNam

extension.generateProtoTasks.ofSourceSet(protoSourceSetRoot).forEach { genProtoTask ->
configureSourceSets(sourceSetName, protoSourceSetRoot, genProtoTask)

// todo: it would be better to avoid this by making the outputs of genProtoTask an input of the correct compile task
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also like to do this correctly if at all possible.

@andrewparmet andrewparmet marked this pull request as ready for review December 15, 2024 21:30
@andrewparmet andrewparmet merged commit 484dca0 into open-toast:main Dec 16, 2024
37 checks passed
@andrewparmet andrewparmet deleted the remove-support-for-kotlin-js-plugin branch December 16, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kotlin JS plugin is deprecated
2 participants