Skip to content

Add Kotlin container to Eclipse classpath containers #32

@nniesen

Description

@nniesen

The org.jetbrains.kotlin.core.KOTLIN_CONTAINER is not be added to the Eclipse project .classpath files.

We have multi-module Gradle projects with mixed languages. The Java and Groovy source sets cannot "find" the Kotlin classes without adding the KOTLIN_CONTAINER to the .classpath files.

Eclipse 2022_09 (v4.25)
Plugin from https://s3.eu-central-1.amazonaws.com/github.bvfalcon/kotlin-eclipse/eclipse-releases/2022-09/

I'm currently using this workaround in my ~\.gradle\init.gradle file to fixup the .classpath files:

allprojects {
    if (project.plugins.hasPlugin(EclipsePlugin)) {
        eclipse.synchronizationTasks {
            def fixKotlinContainer = (project.tasks.find({ it.name.matches("^compile.*Kotlin\$")}) != null) // find first kotlin compile task; null if none.
            if (fixKotlinContainer) {
                println "Adding KOTLIN_CONTAINER for ${eclipse.project.name}"
                eclipse.classpath.containers 'org.jetbrains.kotlin.core.KOTLIN_CONTAINER'
            }
        }
    }
}

which gets me the KOTLIN_CONTAINER in my classpath files:

...
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
	<classpathentry kind="con" path="org.jetbrains.kotlin.core.KOTLIN_CONTAINER"/>
	<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions