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

Precompiled script plugin fails to build on Windows if script is saved with CRLF (accessors not resolved) #12248

Closed
vlsi opened this issue Feb 16, 2020 · 1 comment · Fixed by #12250
Assignees
Milestone

Comments

@vlsi
Copy link
Contributor

vlsi commented Feb 16, 2020

Expected Behavior

The precompiled script plugin should compile on all major platforms no matter which ends of lines the file has.

Current Behavior

If my-plugin.gradle.kts is saved with CRLF ends-of-lines, the plugin can't be compiled on Windows.

This sounds super strange, but I can reproduce it reliably.

The workaround is to ensure .gradle.kts is saved with LF, so I add src/main/kotlin/**/*.gradle.kts text eol=lf to my .gitignore.

Context

I want to split build logic to a precompiled plugin, however, it leads to an extremely hard to understand failure :(

Steps to Reproduce

Note: it requires Windows. I can't reproduce the failure in my macOS.

build.gradle.kts:

plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
}

configure<KotlinDslPluginOptions> {
    experimentalWarning.set(false)
}

src\main\kotlin\my-plugin.gradle.kts:

plugins {
    `java-library`
}

// compileJava is a generated accessor
// However, Gradle fails to resolve it if .gradle.kts is written with CRLF end-of-lines :(
tasks.compileJava {
}

gradlew.bat build:

\src\main\kotlin\my-plugin.gradle.kts: (5, 7): Unresolved reference: compileJava
...
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> Compilation error. See log for more details

Your Environment

Gradle 6.1.1

Sample failure in GitHub Actions (note that both Linux and macOS builds work there, while Windows fails to build buildSrc): https://github.com/weisJ/darklaf/runs/448020434?check_suite_focus=true#step:4:26

@bamboo bamboo self-assigned this Feb 16, 2020
@bamboo bamboo added this to the 6.3 RC1 milestone Feb 16, 2020
bamboo added a commit that referenced this issue Feb 16, 2020
…essors

By normalising the line separators in the script text before computing its hash.

Fixes #12248
@erikc5000
Copy link

I've been seeing weird errors with precompiled script plugins on one (Windows) machine since Gradle 6.1. This seems to be what was causing it. Doesn't happen with 6.0.1. Glad to finally understand what was happening!

bamboo added a commit that referenced this issue Feb 18, 2020
…essors

By normalising the line separators in the script text before computing its hash.

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

Successfully merging a pull request may close this issue.

4 participants