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

Add contribution model for application configuration #1109

Open
bdemers opened this issue Jul 17, 2020 · 7 comments
Open

Add contribution model for application configuration #1109

bdemers opened this issue Jul 17, 2020 · 7 comments

Comments

@bdemers
Copy link

bdemers commented Jul 17, 2020

I would love to be able to create a new project that contains an application.yml instead of an application.properties file.

Maybe as an option? properties=yaml

Or maybe whiteSpaceBugs=true :trollface:
Joking aside, we commonly give instructions to rename app.props to app.yml after creating a new project and then provide example configuration in YAML format.

I can understand the desire to keep the number of permutations down, so feel free to close this issue!

Thanks again!

@snicoll snicoll changed the title Idea: Add option to create a project with an application.yml Add option to create a project with yaml-based configuration Jul 20, 2020
@snicoll
Copy link
Contributor

snicoll commented Jul 20, 2020

I can understand the desire to keep the number of permutations down,

Yep, that's what happening here. This was raised a few times and I understand the interest but I can't see that happening at the moment. I've flagged this for team attention to see what the rest of the team things. I've also moved that to the library as I don't think this would be 100% on the service-side only.

@snicoll snicoll transferred this issue from spring-io/start.spring.io Jul 20, 2020
@wilkinsona
Copy link
Contributor

It feels to me like something that the library could support but we'd choose not to use it on start.spring.io.

@snicoll
Copy link
Contributor

snicoll commented Jul 21, 2020

Yeah although the current contributor right now create an empty file. If we support yaml-based config, It would make sense to offer a model where users can contribute keys and then the configuration is written in either format. If we decide not to use this on start.spring.io, I'd argue we have other areas of the library that needs improving with more impacts on our service.

@wilkinsona
Copy link
Contributor

If we decide not to use this on start.spring.io, I'd argue we have other areas of the library that needs improving with more impacts on our service.

I agree.

@snicoll snicoll changed the title Add option to create a project with yaml-based configuration Add contribution model for application configuration Aug 11, 2020
@snicoll
Copy link
Contributor

snicoll commented Aug 11, 2020

I've repurposed this issue as an enhancement in the library.

@uqix
Copy link

uqix commented Oct 29, 2021

As a workaround:

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import io.spring.initializr.generator.project.contributor.ProjectContributor;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
class DeleteFileProjectContributor implements ProjectContributor {

    private final String path;

    @Override
    public void contribute(final Path projectRoot) throws IOException {
        final var file = projectRoot.resolve(path);
        Files.delete(file);
    }

    @Override
    public int getOrder() {
        return 1;
    }
}

@ProjectGenerationConfiguration
class CustomProjectGenerationConfiguration {
    @Bean
    ProjectContributor deleteApplicationPropertiesProjectContributor() {
        return new DeleteFileProjectContributor("src/main/resources/application.properties");
    }
}

@expe-elenigen
Copy link

I'm sorry if I highjack this ticket, but I feel the real question should be, why using application.properties as the default configuration file instead of application.yml?
The properties files came first, so I get it many people were used by this, but considering yaml is supported since a while and technically I just feel it's hard not to see that properties are way more verbose and they don't follow the DRY principe. It's fine if some people insist on using properties, but it's still technically a better practice in my opinion adopt yaml files and this tool is, for now, sending the wrong message:

Adopt properties files in your app!

I don't mind creating a new ticket if it helps to consider this option, I was just feeling if my suggestion is took in consideration and adopted, then this ticket would lose a lot of interest.

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

5 participants