Skip to content

Configure languageVersion via toolchain#5735

Closed
Goooler wants to merge 14 commits intodetekt:mainfrom
Goooler:use_toolchain
Closed

Configure languageVersion via toolchain#5735
Goooler wants to merge 14 commits intodetekt:mainfrom
Goooler:use_toolchain

Conversation

@Goooler
Copy link
Copy Markdown
Contributor

@Goooler Goooler commented Jan 27, 2023

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 27, 2023

Codecov Report

Merging #5735 (e6c7329) into main (06e38d3) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##               main    #5735   +/-   ##
=========================================
  Coverage     84.66%   84.66%           
  Complexity     3833     3833           
=========================================
  Files           548      548           
  Lines         13058    13058           
  Branches       2302     2302           
=========================================
  Hits          11056    11056           
  Misses          868      868           
  Partials       1134     1134           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Copy Markdown
Member

@3flex 3flex left a comment

Choose a reason for hiding this comment

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

I did something very similar in #5676 and reverted in #5685 because:

The original PR only was only half a solution - it meant that all builds effectively ran on Java 1.8 regardless of which Java version the Gradle build was running. This is fine for the main source build but not for tests, which we want to run on multiple Java versions.

If you can make updates to allow for that then I'd be happy to approve but there'll likely be config changes to a few places in the build and potentially the GitHub workflows as well.

@github-actions github-actions Bot added the ci label Jan 28, 2023
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 28, 2023

Warnings
⚠️ It looks like this PR contains functional changes without a corresponding test.
⚠️ This PR is approved with no milestone set. If merged, it won't appear in the detekt release notes.

Generated by 🚫 dangerJS against e6c7329

@Goooler
Copy link
Copy Markdown
Contributor Author

Goooler commented Jan 28, 2023

I was noticing that too, the solution might be Build on latest Java, test through lowest Java, but there is a NoSuchMethodError in detekt-compiler-plugin test

CompilerTest > with a source file that contains violations() FAILED
    java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments.setSingleModule(boolean)'
        at app//com.tschuchort.compiletesting.KotlinCompilation$commonK2JVMArgs$1.invoke(KotlinCompilation.kt:359)
        at app//com.tschuchort.compiletesting.KotlinCompilation$commonK2JVMArgs$1.invoke(KotlinCompilation.kt:300)
        at app//com.tschuchort.compiletesting.AbstractKotlinCompilation.commonArguments(AbstractKotlinCompilation.kt:133)
        at app//com.tschuchort.compiletesting.KotlinCompilation.commonK2JVMArgs(KotlinCompilation.kt:300)
        at app//com.tschuchort.compiletesting.KotlinCompilation.compileJvmKotlin(KotlinCompilation.kt:488)
        at app//com.tschuchort.compiletesting.KotlinCompilation.compile(KotlinCompilation.kt:664)
        at app//io.github.detekt.compiler.plugin.util.CompilerTestUtils.compile(CompilerTestUtils.kt:21)
        at app//io.github.detekt.compiler.plugin.CompilerTest.with a source file that contains violations(CompilerTest.kt:11)

Comment thread build-logic/src/main/kotlin/module.gradle.kts Fixed
Comment thread build-logic/src/main/kotlin/module.gradle.kts Fixed
Comment thread build-logic/src/main/kotlin/module.gradle.kts Fixed
Comment thread build-logic/src/main/kotlin/module.gradle.kts Fixed
Comment thread build-logic/src/main/kotlin/module.gradle.kts Fixed
Comment thread build-logic/src/main/kotlin/module.gradle.kts Fixed
@3flex
Copy link
Copy Markdown
Member

3flex commented Jan 28, 2023

The test task is currently disabled on detekt-compiler-plugin, so these auto generated tasks should be disabled on that project too.

@Goooler
Copy link
Copy Markdown
Contributor Author

Goooler commented Jan 28, 2023

Disabled. Let's see the impacts on build time.

@3flex
Copy link
Copy Markdown
Member

3flex commented Jan 28, 2023

Yeah that was going to be my next point, but I wanted to see the actual CI runtimes first.

They're not good (which is expected). The loss of parallelism for test execution on the different JVM versions really hurts. This tradeoff isn't worth it just to use toolchains.

@cortinico
Copy link
Copy Markdown
Member

The loss of parallelism for test execution on the different JVM versions really hurts.

+1 for this. I'd rather keep explicit Java versions in the CI matrix as it's also easier for users to understand which version of Java broke

@Goooler
Copy link
Copy Markdown
Contributor Author

Goooler commented Jan 30, 2023

Agreed, I'll leave this PR open until we find a new way to optimize, for the same reason, there is a regression of using toolchain in pinterest/ktlint#1787.

# Conflicts:
#	.github/workflows/pre-merge.yaml
#	build.gradle.kts
@Goooler
Copy link
Copy Markdown
Contributor Author

Goooler commented Mar 20, 2023

It looks fine for now.

@Goooler Goooler marked this pull request as ready for review March 20, 2023 04:30

plugins {
id("com.gradle.enterprise") version "3.12.4"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not needed for Windows specifically, it's required any time a requested JDK is not found locally. It's a requirement in most cases if using toolchains.

More here: https://docs.gradle.org/current/userguide/toolchains.html#sub:download_repositories

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep.

# Conflicts:
#	build-logic/src/main/kotlin/module.gradle.kts
#	detekt-gradle-plugin/settings.gradle.kts
@picklebento
Copy link
Copy Markdown
Member

Is this PR still blocked? Could we make a call on whether to move forward or to close this?

@cortinico
Copy link
Copy Markdown
Member

My 2 c here: I'd love us to use jvmToolchain here but I'm not a big fan on adding yet another Gralde plugin to handle the Win case. So I'd rather close this for now and get back to it?

@3flex
Copy link
Copy Markdown
Member

3flex commented Sep 8, 2023

I'm going to close this, though not because of the foojay plugin (that's essentially a requirement to use toolchains outside of controlled environments where JDKs are all pre installed).

Instead I'd like to wait until this is ready later this year: gradle/build-tool-roadmap#61

We can then just use a standard config to set up the test suites instead of developing a custom one. Things are working ok as they are so there's no real reason to switch yet.

@3flex 3flex closed this Sep 8, 2023
@detekt-ci
Copy link
Copy Markdown
Collaborator

Warnings
⚠️ It looks like this PR contains functional changes without a corresponding test.
⚠️ This PR is approved with no milestone set. If merged, it won't appear in the detekt release notes.

Generated by 🚫 dangerJS against e6c7329

@Goooler Goooler deleted the use_toolchain branch September 8, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants