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

[YAML] [Structure] [Suggestion] Use lists rather than maps #175

Open
JamesYeoman opened this issue Sep 25, 2018 · 5 comments
Open

[YAML] [Structure] [Suggestion] Use lists rather than maps #175

JamesYeoman opened this issue Sep 25, 2018 · 5 comments

Comments

@JamesYeoman
Copy link

JamesYeoman commented Sep 25, 2018

The current structure

dependencies:
- {groupId: ch.qos.logback, artifactId: logback-classic, version: '${logback.version}'}
- {groupId: ch.qos.logback, artifactId: logback-core, version: '${logback.version}'}

just doesn't look quite right. What I had imagined it as is something like this

dependencies:
  - groupId: ch.qos.logback
    artifactId: logback-classic
    version: ${logback.version}
  - groupId: ch.qos.logback
    artifactId: logback-core
    version: ${logback.version}

The use of lists rather than maps actually makes it easier to read (although, that is subjective).

@mosabua
Copy link
Member

mosabua commented Sep 25, 2018

Not sure how that is logic to imply groupId and artifactId but no version.

@mosabua
Copy link
Member

mosabua commented Sep 25, 2018

If anything I can image:

dependencies:
  - groupId: ch.qos.logback
    artifactId: logback-classic
    version: ${logback.version}
  - groupId: ch.qos.logback
    artifactId: logback-core
    version: ${logback.version}

@JamesYeoman
Copy link
Author

JamesYeoman commented Sep 27, 2018

Not sure how that is logic to imply groupId and artifactId but no version.
If anything I can image:

dependencies:
  - groupId: ch.qos.logback
    artifactId: logback-classic
    version: ${logback.version}
  - groupId: ch.qos.logback
    artifactId: logback-core
    version: ${logback.version}

The implying was kinda just me over-DRYing. Your suggestion is basically what I was shooting for. I just tried to group the artifacts by common groupIds

I will update the OP now

EDIT
I have now updated it

@jdimeo
Copy link

jdimeo commented Apr 26, 2020

Aren't these the same thing and both supported by YAML syntax?

@dragetd
Copy link

dragetd commented Mar 8, 2021

- {foo: bar, bleep: bloop}
- {foo2: bar, bleep2: bloop}

is equivalent to

- foo: bar
  bleep: bloop
- foo2: bar
  bleep2: bloop

Both are a list of mappings. The curly braces are just a short-form for writing a map. The YAML parser should treat both the same.

But by far my favorite way to write deps is using the id setting:

dependencies:
  - id: "org.springframework.boot:spring-boot-starter-web"
  - id: "org.mapstruct:mapstruct:1.4.2.Final"

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

No branches or pull requests

4 participants