-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Keep comments in toml file #18
Comments
This was reported in #1 already, and currently the only workaround would be to restore the comment from version history as the parser does not record comments and with sorting/reordering I don't think there would be a good way to keep the comments with the correct entry (the comment could potentially mark a whole section of things). |
It's a pity. It seems a blocker for us because we have loads of comments as described in expected behavior. As I understand, this might add some clarifications toml-lang/toml#836 for the problem. |
I understand. It's impossible to understand such semantics without supporting in toml format. |
Yes, I understand your use case, it makes sense. One other area for comments could be providing some hints to the plugin itself, so I would like to be able to somehow parse them.
|
@hvisser how about something like tokenization and put in VersionCatalog class during parsing several service types like comments and blank lines? |
I think what I'll try is to do a second pass over the toml file because the Jackson parser does not provide any integration point to get to the tokens being parsed, I'll leave this open for now :) |
I see there is a toml parser that supports comments. While searching also found comparison of different toml parsers in kotlin. |
Thanks for that, I've checked out a few and they are either not compliant with the current toml spec and fail on parsing the syntax Gradle is using, or they skip comments. I did a quick check on ktoml and it seems that they also skip comments (and that project seems to be in an early state). I'll try the second pass route first, it might not be that bad as I thought initially given the restricted syntax of the Gradle toml file. |
I would also appreciate mode when this plugin will keep exactly the same toml file, just update versions inside of it. |
It also automatically convert |
That's very unlikely to happen, not only for technical reasons, but also because one of the goals is to have consistent toml file. The formatting serves the same purpose as other formatters: it keeps the file consistent and it prevents bike shedding discussions on teams. There are multiple ways you can write the same thing in a (Gradle) toml file and the reasoning now is to pick the simplest syntax possible, just like described in the Gradle docs. |
Yes. I definitely want to keep exactly the same format for all items, it is the reason why I want to keep versions separated as an extra parameter and don't mix two different possibilities how to write it. Simply:
Yes. it is not the simplest way but definitely uniform across the whole file. |
As I tried to point out the plugin is opinionated towards using the most simple syntax possible per Gradle docs, so I have no plans to change this. Let's also keep this issue on the topic of retaining comments in the toml file. |
+1, thrilled to discover this plugin but I also use many comments in the TOML file which I wouldn't want to lose. |
Do a crude pass for locating comments and write them out to the toml file. Comments are associated with toml table declarations and keys within the tables, so they can move around and be removed if a key or a whole table is removed. Fixes #18
Environment:
nl.littlerobots.version-catalog-update: 0.2.1
com.github.ben-manes.versions: 0.41.0
Gradle: 7.3.2
libs.versions.toml:
Scenario:
Result:
libs.versions.toml:
Expected behavior:
The plugin can't know about semantics but shouldn't erase it from the config.
Here is the source of truth for versions. This is why we keep knowledge about versions here.
libs.versions.toml:
The text was updated successfully, but these errors were encountered: