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

Classpath container include 'build/main' entries when using Kotlin 1.8.20 #1238

Open
philwebb opened this issue Apr 24, 2023 · 8 comments
Open

Comments

@philwebb
Copy link

Expected Behavior

When importing a project that has the Kotlin Gradle plugin the eclipse classpath should not include entries for the build/classes/java and build/classes/kotlin. Having these additional entries makes Eclipse hard to use. For example, searching for a type will find both the source code and the previously built .class file.

Current Behavior

When using Kotlin 1.8.20 additional classpath entries are added. Downgrading to Kotlin 1.8.10 fixes the issue.

Context

Originally discovered in spring-projects/spring-boot#35101

Steps to Reproduce

https://github.com/philwebb/kotlin-buildship-classpath-bug

Your Environment

Details are in the reproducer project readme

@donat
Copy link
Contributor

donat commented Apr 25, 2023

The org.jetbrains.kotlin.jvm plugin contributes the build directories to the testCompileClasspath. Buildship puts both the production and the test dependencies to the same classpath, that's why you see it. There are a couple of workarounds you can do:

  • Remove offending dependencies by modifying eclipse.classpath.plusConfigurations and/or eclipse.classpath.minusConfigurations (given your test and production code are in different subprojects)
  • adjust the eclipse classpath via the eclipse.classpath.file.whenMerged {} callback.

@philwebb
Copy link
Author

Thanks @donat! This commit did the trick for us spring-projects/spring-boot@13d00d8

@wilkinsona
Copy link

@donat I think we have a similar problem with Spring Boot's Gradle Plugin for ahead-of-time processing. Is this something that you can fix in Buildship? My expectation was that it would "deduplicate" build/classes/java and bin/main, only keeping the latter as it's the Eclipse-specific equivalent of the former.

@dsyer
Copy link

dsyer commented Apr 26, 2023

See also #1236 (probably would be fixed the same way - de-deuplication of classpath entries).

@sellmair
Copy link

sellmair commented May 5, 2023

Kotlin 1.9.0 will restore the behaviour in 1.8.10

@sellmair
Copy link

Unfortunately, we detected that reverting the behaviour back to 1.8.10 clashes with a workaround applied for:
https://youtrack.jetbrains.com/issue/KT-58280/org.jetbrains.kotlin.jvm-Gradle-plugin-contributes-build-directories-to-the-test-compile-classpath

Which relates to gradle/gradle#23932

I therefore need to revoke the previous message. We are aiming to restore behaviour in 1.9, but the first attempt failed and the initial beta is right around the corner already.

cc @Tapchicoma

@wilkinsona
Copy link

AIUI, the NBT Gradle Plugin also configures things in such a way that build/main entries end up on the classpath when using Buildship. IMO, it would be better to fix this at source in Buildship rather than multiple plugins all working around the problem.

@sellmair
Copy link

For now, the change in KGP was reverted and will likely be shipped in 1.9.0-Beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants