Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Integrate Kotlin src-dependencies into the workflow with gradle(task: generateXtext fails with Kotlin-Class-Dependency in xtend files)
Integrate Kotlin src-dependencies into the workflow with gradle [message #1833107] Fri, 02 October 2020 11:32 Go to next message
Jan Hermes is currently offline Jan HermesFriend
Messages: 27
Registered: September 2020
Junior Member
Hello Xtexters,

I'm currently working on a project with which I would like to use preexisting kotlin-src-files.

Unfortunately, when I reference classes defined in kotlin files I get an error about unresolved references from the generateXtext task in gradle.

The project configuration is as follows (adapted from here: https://github.com/itemis/xtext-languageserver-example

"build.gradle" in parent-project:

plugins {
        // ...
        // added kotlin jvm plugin:
  	id "org.jetbrains.kotlin.jvm" version "1.4.10" apply false
        // ...
}

// ...
configure(subprojects.findAll { it.name.startsWith('org.example') }) {

	ext.xtextVersion = '2.23.0'
	repositories {
		mavenCentral()
		jcenter()
	}
	apply plugin: 'kotlin'

	compileKotlin {
		kotlinOptions {
			jvmTarget = "11"
		}
	}
        // ...
}
// ...


Then in the main-language subproject (org.example.mydsl) I just added "compileKotlin" as a dependency to the generateXtext task:

// ...
generateXtext.dependsOn(compileKotlin)
generateXtext.dependsOn(generateXtextLanguage)
// ...


When I run
./gradlew :org.example.mydsl:generateXtext

it fails with errors to unresolved references to kotlin-classes that are referenced in xtend-files

Do you know how I can make the generateXtext task become aware of the compiled kt-classes in the virtual folder kotlin_bin?

Regards,
Jan Hermes

Re: Integrate Kotlin src-dependencies into the workflow with gradle [message #1833108 is a reply to message #1833107] Fri, 02 October 2020 11:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
sorry, i fear nobody has tried that yet. i am also not sure if this works with circular deps you have.
is there any reason you use xtend at all if you use kotlin?

maybe you can put the kotlin outputs to the classpath for generateXtext somehow.
(feeding them to compile depns or intoduce a own sourceset + add it as dep there)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 02 October 2020 11:52]

Report message to a moderator

Re: Integrate Kotlin src-dependencies into the workflow with gradle [message #1833110 is a reply to message #1833108] Fri, 02 October 2020 12:07 Go to previous messageGo to next message
Jan Hermes is currently offline Jan HermesFriend
Messages: 27
Registered: September 2020
Junior Member
Ok thanks for the info..

I think both languages have there advantages and I would rather use them both. But anyway there were preexisting kotlin classes that I could have quickly translated to be integrated with my existing setup if I could use kotlin directly.
Of course I also have the possibility to translate the kotlin-files to xtend or java (preferrably xtend).

--------

Two parts where I really don't want to miss xtend is the code-generator and the extension-dsl (@Inject extension XYZ).

---------

I will try a bit more and report back if I find a solution.
Re: Integrate Kotlin src-dependencies into the workflow with gradle [message #1833112 is a reply to message #1833110] Fri, 02 October 2020 12:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
if there is no interdependency: why not create a separate module and place content there e.g. mydsl.lib

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Integrate Kotlin src-dependencies into the workflow with gradle [message #1833114 is a reply to message #1833112] Fri, 02 October 2020 12:57 Go to previous message
Jan Hermes is currently offline Jan HermesFriend
Messages: 27
Registered: September 2020
Junior Member
I'm a kind of a newbie to the complete java-xtend-gradle project-subproject configuration ecosystem. I will try that out actually. :)
Previous Topic:Why is MyDslFactory.eINSTANCE the common way to get a factory?
Next Topic:java.io.FileNotFoundException
Goto Forum:
  


Current Time: Fri Apr 26 05:32:29 GMT 2024

Powered by FUDForum. Page generated in 0.03935 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top