spring-io / initializr

A quickstart generator for Spring projects
https://start.spring.io
Apache License 2.0
3.44k stars 1.73k forks source link

Support for adding comments to generated build configuration #1490

Open breun opened 10 months ago

breun commented 10 months ago

I'm using MavenBuild.ConfigurationBuilder to generate some Maven plugin configuration in a project that builds on top of Spring Initializr, like this:

appMavenBuild.plugins().add("com.google.cloud.tools", "jib-maven-plugin") { pluginBuilder ->
    pluginBuilder.configuration { configurationBuilder ->
        configurationBuilder.add("container") { containerBuilder ->
            containerBuilder.add("jvmFlags") { jvmFlagsBuilder ->
                jvmFlagsBuilder
                    .add("jvmFlag", "-XX:InitialRAMPercentage=50")
                    .add("jvmFlag", "-XX:MaxRAMPercentage=50")
            }
        }
    }
}

This results in the following XML in pom.xml, as expected:

<plugin>
  <groupId>com.google.cloud.tools</groupId>
  <artifactId>jib-maven-plugin</artifactId>
  <configuration>
    <container>
      <jvmFlags>
        <jvmFlag>-XX:InitialRAMPercentage=50</jvmFlag>
        <jvmFlag>-XX:MaxRAMPercentage=50</jvmFlag>
      </jvmFlags>
    </container>
  </configuration>
</plugin>

Now I'd like to add a comment to the generated jvmFlag entries, like this:

<plugin>
  <groupId>com.google.cloud.tools</groupId>
  <artifactId>jib-maven-plugin</artifactId>
  <configuration>
    <container>
      <jvmFlags>
        <jvmFlag>-XX:InitialRAMPercentage=50</jvmFlag>
        <jvmFlag>-XX:MaxRAMPercentage=50</jvmFlag><!-- See https://example.com/some/url for heap memory sizing recommendations. -->
      </jvmFlags>
    </container>
  </configuration>
</plugin>

I believe the current MavenBuild.ConfigurationBuilder API doesn't provide a way to generate Maven configuration with comments, or am I missing something?

What are your thoughts about extending the API to allow adding comments? I can also see use cases for adding comments in other places in generated build configuration, so maybe it would be a good idea to add support for comments to all add(...) methods in classes in the io.spring.initializr.generator.buildsystem package?

moupriyaroy25 commented 9 months ago

Hi, I have been using spring initializer for more than 6 months to create Springboot application. Mind if I take up this issue and start working on it?

breun commented 9 months ago

I don’t mind, I would love to see this feature added, but I’m just the reporter of this issue. 🙂