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

Jvm.Support.assertFormatterSupported does not support -SNAPSHOT versions #1583

Closed
blacelle opened this issue Feb 23, 2023 · 6 comments
Closed

Comments

@blacelle
Copy link
Contributor

blacelle commented Feb 23, 2023

I consider a Jvm.Support like:

private static final Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support(NAME).add(11, "2.6");

For local developements of the underlying plugin (cleanthat), I would like to run spotless (e.g. with mvn spotless:apply) with a SNAPSHOT version of my plugin (e.g. through the usual <version>2.7</version> (in maven) parameter of many plugins).

It fails with:

Caused by: java.lang.NumberFormatException: For input string: "7-SNAPSHOT"
    at java.lang.NumberFormatException.forInputString (NumberFormatException.java:67)
    at java.lang.Integer.parseInt (Integer.java:668)
    at java.lang.Integer.parseInt (Integer.java:786)
    at java.util.stream.ReferencePipeline$4$1.accept (ReferencePipeline.java:214)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining (Spliterators.java:992)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:575)
    at java.util.stream.AbstractPipeline.evaluateToArrayNode (AbstractPipeline.java:260)
    at java.util.stream.IntPipeline.toArray (IntPipeline.java:562)
    at com.diffplug.spotless.Jvm$Support$SemanticVersionComparator.convert (Jvm.java:246)
    at com.diffplug.spotless.Jvm$Support$SemanticVersionComparator.compare (Jvm.java:229)
    at java.util.TreeMap.compare (TreeMap.java:1570)
    at java.util.TreeMap.getCeilingEntry (TreeMap.java:395)
    at java.util.TreeMap.ceilingEntry (TreeMap.java:1021)
    at com.diffplug.spotless.Jvm$Support.getRequiredJvmVersion (Jvm.java:150)
    at com.diffplug.spotless.Jvm$Support.buildUnsupportedFormatterMessage (Jvm.java:126)
    at com.diffplug.spotless.Jvm$Support.assertFormatterSupported (Jvm.java:119)
blacelle added a commit to blacelle/spotless that referenced this issue Feb 23, 2023
@nedtwigg
Copy link
Member

Fixed in plugin-gradle 6.16.0 and plugin-maven 2.34.0.

@blacelle
Copy link
Contributor Author

blacelle commented Apr 6, 2023

@nedtwigg This seems broken with plugin-maven 2.36.0.

@blacelle
Copy link
Contributor Author

blacelle commented Apr 6, 2023

The stack looks similar than before 2.24.0:

Caused by: java.lang.IllegalArgumentException: Not a semantic version: 2.14-SNAPSHOT
    at com.diffplug.spotless.Jvm$Support$SemanticVersionComparator.convert (Jvm.java:285)
    at com.diffplug.spotless.Jvm$Support$SemanticVersionComparator.compare (Jvm.java:266)
    at java.util.TreeMap.compare (TreeMap.java:1570)
    at java.util.TreeMap.getCeilingEntry (TreeMap.java:395)
    at java.util.TreeMap.ceilingEntry (TreeMap.java:1021)
    at com.diffplug.spotless.Jvm$Support.getRequiredJvmVersion (Jvm.java:178)
    at com.diffplug.spotless.Jvm$Support.buildUnsupportedFormatterMessage (Jvm.java:148)
    at com.diffplug.spotless.Jvm$Support.assertFormatterSupported (Jvm.java:140)
    at com.diffplug.spotless.java.CleanthatJavaStep$JavaRefactorerState.<init> (CleanthatJavaStep.java:134)
    at com.diffplug.spotless.java.CleanthatJavaStep.lambda$create$1 (CleanthatJavaStep.java:97)
    at com.diffplug.spotless.FormatterStepImpl.calculateState (FormatterStepImpl.java:58)
    at com.diffplug.spotless.LazyForwardingEquality.state (LazyForwardingEquality.java:56)
    at com.diffplug.spotless.LazyForwardingEquality.toBytes (LazyForwardingEquality.java:85)
    at com.diffplug.spotless.LazyForwardingEquality.hashCode (LazyForwardingEquality.java:102)
    at java.util.ArrayList.hashCodeRange (ArrayList.java:595)
    at java.util.ArrayList.hashCode (ArrayList.java:582)
    at com.diffplug.spotless.Formatter.hashCode (Formatter.java:276)
    at java.util.HashMap.hash (HashMap.java:338)
    at java.util.HashMap.put (HashMap.java:610)
    at com.diffplug.spotless.maven.FormattersHolder.create (FormattersHolder.java:43)
    at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:224)

Unclear to me how this was fixed.

@nedtwigg nedtwigg reopened this Apr 6, 2023
@nedtwigg
Copy link
Member

nedtwigg commented Apr 6, 2023

Sorry, I think I saw the Add workaround for diffplug#1583 commit above and assumed that this had been fixed as part of another PR.

@blacelle
Copy link
Contributor Author

blacelle commented Apr 6, 2023

On my side, I supposed this was properly fixed, and removed the workaround. Sorry for the confusion.

@nedtwigg
Copy link
Member

Fixed in plugin-gradle 6.19.0 and plugin-maven 2.37.0.

benkard pushed a commit to benkard/mulkcms2 that referenced this issue Aug 29, 2023
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) | build | minor | `2.38.0` -> `2.39.0` |
| [io.quarkus:quarkus-maven-plugin](https://github.com/quarkusio/quarkus) | build | patch | `3.3.0` -> `3.3.1` |
| [io.quarkus:quarkus-universe-bom](https://github.com/quarkusio/quarkus-platform) | import | patch | `3.3.0` -> `3.3.1` |

---

### Release Notes

<details>
<summary>diffplug/spotless</summary>

### [`v2.39.0`](https://github.com/diffplug/spotless/blob/HEAD/CHANGES.md#&#8203;2390---2023-05-24)

##### Added

-   `Jvm.Support` now accepts `-SNAPSHOT` versions, treated as the non`-SNAPSHOT`. ([#&#8203;1583](diffplug/spotless#1583))
-   Support Rome as a formatter for JavaScript and TypeScript code. Adds a new `rome` step to `javascript` and `typescript` formatter configurations. ([#&#8203;1663](diffplug/spotless#1663))
-   Add semantics-aware Java import ordering (i.e. sort by package, then class, then member). ([#&#8203;522](diffplug/spotless#522))

##### Fixed

-   Fixed a regression which changed the import sorting order in `googleJavaFormat` introduced in `2.38.0`. ([#&#8203;1680](diffplug/spotless#1680))
-   Equo-based formatters now work on platforms unsupported by Eclipse such as PowerPC (fixes [durian-swt#&#8203;20](diffplug/durian-swt#20))
-   When P2 download fails, indicate the responsible formatter. ([#&#8203;1698](diffplug/spotless#1698))

##### Changes

-   Equo-based formatters now download metadata to `~/.m2/repository/dev/equo/p2-data` rather than `~/.equo`, and for CI machines without a home directory the p2 data goes to `$GRADLE_USER_HOME/caches/p2-data`. ([#&#8203;1714](diffplug/spotless#1714))
-   Bump default `googleJavaFormat` version to latest `1.16.0` -> `1.17.0`. ([#&#8203;1710](diffplug/spotless#1710))
-   Bump default `ktfmt` version to latest `0.43` -> `0.44`. ([#&#8203;1691](diffplug/spotless#1691))
-   Bump default `ktlint` version to latest `0.48.2` -> `0.49.1`. ([#&#8203;1696](diffplug/spotless#1696))
    -   Dropped support for `ktlint 0.46.x` following our policy of supporting two breaking changes at a time.
-   Bump default `sortpom` version to latest `3.0.0` -> `3.2.1`. ([#&#8203;1675](diffplug/spotless#1675))

</details>

<details>
<summary>quarkusio/quarkus</summary>

### [`v3.3.1`](quarkusio/quarkus@3.3.0...3.3.1)

[Compare Source](quarkusio/quarkus@3.3.0...3.3.1)

</details>

<details>
<summary>quarkusio/quarkus-platform</summary>

### [`v3.3.1`](quarkusio/quarkus-platform@3.3.0...3.3.1)

[Compare Source](quarkusio/quarkus-platform@3.3.0...3.3.1)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This MR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
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

2 participants