-
Notifications
You must be signed in to change notification settings - Fork 206
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
.properties <-> .yml converter #739
Comments
Is this the request for Spring Boot Tools for vscode plugin? |
Here is another related feature request to have yml -> properties convention: spring-attic/spring-ide#331. It looks to me like we have three parts of this:
So this sounds to me like we should move the existing implementation for converting properties -> yml into the language server and make it available via a command to the client. Then, we could serve this as menu item / command in the various clients. Maybe the command can be generic in terms of which conversion should happen so that we can use the same command with different params for converting properties -> yml and then, down the line, for yml -> properties as well (so that the command is on the level of "convert" and the params specify the "to" format maybe. The input file would/could determine the "from" format. |
Another thought here: If we allow the conversion to change the existing file (rename + content conversion), we would need to make sure that the conversion is exact and nothing gets lost in the conversion. This might be hard to achieve. As a consequence, we could also always create a new file (in addition to the existing one) and put the converted content in the new file without deleting the existing file. That would prevent the user from loosing something in case the conversion is not fully complete or missed something. We could also add a preference for this to switch between the modes ("delete file after property conversion") that would be disabled at the beginning and users could enable this if they think the old file should always be deleted. |
Has a lot of sense what you are proposing. In that way keeping the 2 files, the original and converted. Is assumed that in Spring Boot exists a priority about what file to choice if exists both with the same name but with different extension (.properties/.yml/.yaml). But it is other history and is assumed the developer knows what to do - either keep both files or delete the former when the latter was generated from the former (manually or automatically according with your propose). |
We are moving back from yml format to property files, so that automatic conversion would be quite handy to have also in Eclipse STS. Unfortunately, I guess this will come too late for us... |
Let's see what @BoykoAlex things about this when he is back, maybe we can pull something off soonish. |
If I was to do this properly I would:
(Currently in Eclipse the action shows refactor preview. If we are to keep this behaviour then we'd need Perhaps we could add a menu item just for Eclipse to convert boot properties from yaml -> properties? I'm curious how difficult this might turn out to be. This work could later be used for the proper LSP-based solution. Then later we might improve things to keep comments in the right places using OpenRewrite but this would be in a longer term... |
POC in Eclipse seems to work... of course it would need to be unit tested before it goes into the snapshot builds. It also has similar limitations of removing comments as props -> yaml has. |
If you need a tester for Linux, I am here available, it for Ubuntu and Fedora. Same thought for Windows 10. |
Pushed Eclipse only yaml -> props support: 3a0ee63 Try Eclipse snapshots from: https://cdn.spring.io/spring-tools/snapshot/STS4/nightly-distributions.html |
Just to be in the same picture...
Am I correct? |
Sure, just wait 1.5 hours from now for the eclipse distro snapshot build to finish. |
Understood. I am going to test them starting this Friday in the afternoon. |
Report I Working with the installer for windows:
Unpacked and nothing more done prior to start it. Creating at <artifactId>spring-boot-starter-data-jpa</artifactId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>h2</artifactId>
<artifactId>mysql-connector-j</artifactId> Imported in the IDE and editing the spring.application.name=demo
spring.profiles.active=mysql,no-cache
spring.datasource.url=jdbc:h2:mem:ensamble_presentation_v2
spring.datasource.username=sa
spring.datasource.password=password
spring.sql.init.mode=embedded
spring.sql.init.schema-locations=classpath:/com/manuel/jordan/h2/v2/schema-h2.sql
spring.sql.init.data-locations=classpath:/com/manuel/jordan/h2/v2/data-h2.sql
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
spring.messages.basename=i18n/messages,i18n.labels
spring.thymeleaf.cache=true
spring.thymeleaf.enabled=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.mvc.hiddenmethod.filter.enabled=true
server.port=8080 In this
Sorry about the huge size of the Figures, in this way works Ms Paint on Windows 10 Home. Pressed The logging:
level:
org:
hibernate:
SQL: DEBUG
type:
descriptor:
sql:
BasicBinder: TRACE
server:
port: 8080
spring:
application:
name: demo
datasource:
password: password
url: jdbc:h2:mem:ensamble_presentation_v2
username: sa
jpa:
properties:
hibernate:
format_sql: true
show_sql: true
use_sql_comments: true
show-sql: true
messages:
basename: i18n/messages,i18n.labels
mvc:
hiddenmethod:
filter:
enabled: true
profiles:
active: mysql,no-cache
sql:
init:
data-locations: classpath:/com/manuel/jordan/h2/v2/data-h2.sql
mode: embedded
schema-locations: classpath:/com/manuel/jordan/h2/v2/schema-h2.sql
thymeleaf:
cache: true
enabled: true
prefix: classpath:/templates/
suffix: .html Now having the
happens: Is pressed the BTW the error message is: Is not possible delete the The unique way to delete this file is closing and opening the project. Wait few seconds prior to re-open Note: This error happens even if the So the logical question is: What is the other process? Wait me for the report for Ubuntu and Fedora. Thanks for your understanding |
@manueljordan I have just fixed the issue of "the file being used by another process" on Win: e528454 Thanks for giving it a spin :-) |
@BoykoAlex thanks for the quick update for Windows, pls let me know when is ready/built the new installer - it about to wait 1.5hrs
Np - I enjoy this IDE |
Report II Working with the installer for Linux (Ubuntu and Fedora):
Unpacked and nothing more done prior to start it. Same instructions as indicated for Windows experience, it works fine, but appears the following: The warning message is the same for the three points And just in case, that Warning message appeared just once in Windows too, but not anymore, it remains in Linux/Ubuntu. I am assuming it would happen and should remain as in Linux, it based with the new installer As summary:
Thanks to your quick patch and I did do realize and confirmed that any comment disappears. And finally:
|
It seems it is almost completed (I must re-test Windows), but I did do realize the following.
Thanks for your understanding |
@manueljordan build has succeeded and ready to for testing |
@BoykoAlex it works fine now, same behavior as Linux. |
@manueljordan awesome!!! Thanks very much for testing!-) I'm moving the refactoring logic on the Boot LS side now to make yaml <-> props conversions available in both Eclipse and VSCode (and Theia therefore). |
@BoykoAlex no problem :) - let me know your thoughts about points 1 and 2. |
@manueljordan Regarding the two points:
|
Thanks @BoykoAlex Understood. It seems they are candidates to create two new issues. And even would exist a 3rd one, it to suggest and apply a refactoring to solve the mentioned warning messages shown in the |
@manueljordan I'd create 2 additional issues once this issue is resolved as there is a chance to resolve them once conversion is an LS command. Is the 3rd issue about warnings/errors inside of the produced yaml files in a form of comments? |
Yes, about that |
Pushed in the Boot LS based yaml <-> props conversion. It is now available on both VSCode and Eclipse. I was able to somewhat maintain the order of keys for props -> yaml conversion. The undo still didn't work properly in Eclipse therefore in Eclipse you'd be only able to create new file without replacing the old. The old file could be replaced in VSCode if preference setting for replacing the old file is on (by default it is off). The change is: aed2127 |
Sounds great.
Two files in parallel, right? .properties and .yaml? |
@manueljordan Exactly - in the same folder. |
A command to automatically convert properties to YAML files (and vice versa) would be very handy.
The text was updated successfully, but these errors were encountered: