OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
126 stars 90 forks source link

In liberty:create goal, liberty-plugin-config.xml doesn't reflect precedence of liberty.bootstrap.* props over <bootstrapPropertiesFile> plugin config #1788

Closed scottkurz closed 7 months ago

scottkurz commented 8 months ago

Using v3.10, with pom.xml property and plugin config like:

    <properties>
        <liberty.bootstrap.name>intro</liberty.bootstrap.name>
  ...
            <plugin>
                <groupId>io.openliberty.tools</groupId>
                <artifactId>liberty-maven-plugin</artifactId>

                <configuration>
                    <bootstrapPropertiesFile>${project.basedir}/src/main/liberty/config/c.properties</bootstrapPropertiesFile>

both the 'create' and 'deploy' goals will generate a 'bootstrap.properties' file from the liberty.bootstrap.name property. The <bootstrapPropertiesFile> config will be ignored.

However, if you look at the liberty-plugin-config.xml, the 'deploy' goal will write the correct, individual property, matching the generated 'bootstrap.properties' file:

    <bootstrapProperties>
        <name>intro</name>
    </bootstrapProperties>

while the 'create' goal will write:

    <bootstrapPropertiesFile>C:\ydosppa\application-stack-intro\src\main\liberty\config\c.properties</bootstrapPropertiesFile>

The reason seems to be that the precedence incorporating the liberty.bootstrap.* project props is encoded in the io.openliberty.tools.maven.server.StartDebugMojoSupport.copyConfigFiles() method, which gets called BEFORE the liberty-plugin-config.xml is written in the 'deploy' goal, but only gets called AFTER the plugin config is written in the 'create' goal.

From the doc, https://github.com/OpenLiberty/ci.maven/blob/main/docs/common-server-parameters.md, it doesn't specifically mention the liberty.bootstrap.* project props but it does say that plugin config parm <bootstrapProperties> takes precedence over <bootstrapPropertiesFile>, so the generated properties seem correct and the plugin cfg xml seems wrong.

In dev mode, a create then a deploy is typically done, so the practical impact of this may be almost zero today.

But as Liberty Tools (IDE support) adds more usage of the liberty-plugin-config.xml maybe this should be fixed.

I know this is a long writeup for possibly a 1-line change of writing the plugin cfg maybe after copyConfigFiles in the create goal... but wanted to make sure we understood clearly first :)

cherylking commented 8 months ago

Thanks for the details Scott. Makes sense.

cherylking commented 8 months ago

Make sure LGP does the right thing also when fixing this.