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

Kotlin support #356

Merged
merged 115 commits into from
Jun 29, 2021
Merged

Kotlin support #356

merged 115 commits into from
Jun 29, 2021

Conversation

oowekyala
Copy link
Collaborator

@oowekyala oowekyala commented Jun 4, 2021

This adds support for writing code in Kotlin. The output language of Xtext is now Java, not Xtend. The gradle and maven builds are updated to make the kotlin compiler run. They're also patched to work around Xtext regenerating Java files. Namely there's a short list of those files here and here

The build process now runs like so:

  1. generate Java from Xtend sources (with Java sources in sourcepath)
  2. generate bytecode from Kotlin sources (with output of step 1 in sourcepath)
  3. generate bytecode from Java sources produced by step 1 (with Kotlin bytecode in classpath)

This means

  • Xtend sources may use only Xtend and Java sources,
  • Kotlin and Java sources may use all of Kotlin, Java, and Xtend sources.

Many files are ported from Xtend to Kotlin or Java. Note that #345 is built on these changes.

TODO

  • Tests are run during the maven build, but we could also disable them, since the CI only uses gradle.
  • Since 4c0f025 I'm not sure we need cca6fdc. But I'm not sure what generates the .target file either.. @a-sr could you take a look?

closes #337

oowekyala and others added 30 commits April 21, 2021 18:15
Problem is, Xtend sources do not see the Kotlin classes.
I assume the Xtend actually integrates a Java compiler and
can compile mixed codebases of Java+Xtend. The Kotlin compiler
does the same. But mixing both introduces a circular dependency.
This reverts commit d279963.
We can rewrite it to kotlin automatically later
We need to port the C++ generator for that to work
Kotlin extensions are much more ergonomic.
Where do they come from? why do I need to do this?
@oowekyala oowekyala marked this pull request as ready for review June 24, 2021 16:33
@cmnrd cmnrd force-pushed the kotlin-with-gradle branch from 6f34d41 to 0ef09e6 Compare June 25, 2021 12:39
cmnrd and others added 4 commits June 25, 2021 14:54
This makes it easier to debug LFC when you build
the project with Gradle, including from within
Intellij.

Use with

  gradle :org.lflang:runLfc --args '-c example/C/src/Smokers.lf'
@@ -81,3 +81,13 @@ task generateStandaloneCompiler() {
}

generateStandaloneCompiler.finalizedBy shadowJar

task runLfc(type: JavaExec) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting. Do you know that the lfc script is capable of something similar? If you run lfc -r, it rebuilds itself via gradle before running.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah ok I didn't know. I added the gradle task to be able to run & debug it from intellij, I'm not sure it would be possible with a bash script

Copy link
Collaborator

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

It should be safe to merge this now!

Since this MR does not include any Kotlin files that are actually used, no one should notice a difference. Mostly, this MR changes configurations so that Kotlin files can be compiled in Gradle, Maven and (only in theory...) in Eclipse.

When merging this, we should notify everyone to do a fresh oomph install. I would also recommend to use a fresh git clone for this. This is because we removed several xtend files, but heir generated artifacts are not under version control. If the xtend-gen artifacts are not deleted manually (or by using a fresh clone), there will likely be build errors due to duplicated class definitions. This is also important to know when switching between branches.

While testing the new oomph setup, I noticed to issues. First, messages like "Kotlin Analysis" has encountered a problem tend to appear sometimes. Second, my install always results in a state where there are errors shown for org.lflang.web. However, triggering recompilation of the files or cleaning this project removes the error messages.

@lhstrh lhstrh merged commit d845833 into master Jun 29, 2021
@lhstrh lhstrh deleted the kotlin-with-gradle branch June 29, 2021 20:57
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.

Configure Maven to compile Kotlin code
4 participants