spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Remove `toLines(` and use `toContent("""` instead

Open nedtwigg opened this issue 2 years ago • 2 comments

It would be really convenient if our tests could use multiline string literals. Then we could remove some of this cuteness

https://github.com/diffplug/spotless/blob/aa78b56544ea55abd4cea673c7aaabb5c3da3fcc/testlib/src/main/java/com/diffplug/spotless/ResourceHarness.java#L184-L186

https://github.com/diffplug/spotless/blob/aa78b56544ea55abd4cea673c7aaabb5c3da3fcc/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/ConfigurationCacheTest.java#L50-L61

Right now we test on two platforms - jdk11 and jdk17. But once #1304 gets figured out, we could run our build on Java 17, up the source level to 17 for tests, and use Gradle toolchain to run tests against jre 11 + 17.

That might be too complicated, and java 11 LTS reaches end of life in 2026 which will be here before we know it anyway. But if you made a PR that

  • preserved the existing test matrix
  • but always used java 17 as the build jre
  • compiled bytecode to java 11 for the jars
  • compiled bytecode to java 17 for the tests

That would be welcome and quickly merged!

nedtwigg avatar Jan 26 '23 21:01 nedtwigg

Use toolchains?

https://docs.gradle.org/current/userguide/toolchains.html https://jakewharton.com/build-on-latest-java-test-through-lowest-java

Goooler avatar Feb 21 '23 17:02 Goooler

17 is our minimum now, so this is doable. Would be nice to replace all our toLines() with toContent(""". Should be easier to read. Good job for claude to do, don't waste human time on this.

nedtwigg avatar Jul 21 '25 19:07 nedtwigg