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

Add Kotlin support #120

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Add Kotlin support #120

wants to merge 1 commit into from

Conversation

Arthurm1
Copy link
Contributor

Adds Kotlin support.

I don't use Kotlin but I thought it would be good to get support for a few languages to help decide on best design for handling multiple languages.

BSP spec is not finalised for Kotlin. See here. I've no idea about how to setup associates in a Gradle build so I've ignored it.

Kotlin plugin doesn't seem to be part of Gradle so everything here is done with reflection - I guess you could add the Kotlin library into the plugin project if you don't want to use reflection.

Up to you if you want to merge. I could change this to a draft PR.

@@ -109,17 +122,49 @@ private List<String> getBuildTargetTags(boolean hasTests) {
return tags;
}

private void setJvmBuildTarget(GradleSourceSet sourceSet, BuildTarget bt) {
private void setBuildTarget(GradleSourceSet sourceSet, BuildTarget bt) {
if (sourceSet.isKotlin()) {
Copy link
Member

Choose a reason for hiding this comment

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

If a source set applies kotlin, scala & java plugins, then which one should be returned as the data of the build target?

I've not idea about this. I asked this question in the BSP discord channel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've no idea either. I doubt it's possible. I think that both the Scala and Kotlin plugins are Java aware and able to mix in their languages with Java so you could have Java classes referencing Scala classes and vice versa in the same project. But neither plugin is aware of the other language so Scala wouldn't know what to do with Kotlin and Kotlin wouldn't know what to do with Scala. Happy to be corrected on this but I think the code would have to be in separate projects.

Copy link
Member

@jdneo jdneo Dec 20, 2023

Choose a reason for hiding this comment

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

Searched in google and found that there are some people doing that: https://discuss.gradle.org/t/kotlin-groovy-and-java-compilation/14903/8.

But I guess that's a very rare case.


Update:

Looks like BSP team is targeting to address this in 3.0: build-server-protocol/build-server-protocol#487

Basically, allowing multiple build target data.

@Arthurm1
Copy link
Contributor Author

Arthurm1 commented Apr 1, 2024

rebased

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.

2 participants