bnd
bnd copied to clipboard
BndConfiguration.getConfiguration(List<Plugin>) does not take into account global configuration
The code at https://github.com/bndtools/bnd/blob/f9b2c857859dd3e46401f2f19aba4b09f308a16e/biz.aQute.bnd.maven/src/aQute/bnd/maven/lib/configuration/BndConfiguration.java#L114 does not take the global configuration into account.
For example if the parent pom has something like
...
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<executions>
<execution>
<id>bnd-process</id>
<goals>
<goal>bnd-process</goal>
</goals>
<configuration>
<bnd>Bundle-Category: Something</bnd>
</configuration>
</execution>
</executions>
</plugin>
and the child pom has
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<configuration>
<bnd>Fragment-Host: some-bsn</bnd>
</configuration>
</plugin>
The configuration being returned by https://github.com/bndtools/bnd/blob/f9b2c857859dd3e46401f2f19aba4b09f308a16e/biz.aQute.bnd.maven/src/aQute/bnd/maven/lib/configuration/BndConfiguration.java#L114 for the plugin of the child pom is just containing the configuration of the parent POM.
The logic is missing some merge logic between execution configuration and global configuration (compare also with https://stackoverflow.com/questions/33908315/what-is-the-difference-between-executions-and-configurations-in-a-maven-plugin).
Would you be able to do a PR?
I am still trying to work out the inner Maven logic. We need to reproduce it in bnd due to the bnd instruction inheritance which deviates a bit from the Maven Plugin configuration inheritance
I found https://github.com/apache/maven/blob/maven-3.9.x/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java, but not sure yet when this kicks in.
I opened https://issues.apache.org/jira/browse/MNGSITE-544 to document the status quo a bit better.
I think this is actually expected and nothing bnd should/need to handle because maven already merges the configurations appropriately..
In your child you provide a configuration that would apply to all executions but in your specific execution you override this so it is merged with the plugin one and effectively overriding what is configured in the child. This would be different if you specify an additional execution without configuration, then your general configuration will take precedence.
To accomplish what you described your child configuration must look like this:
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<executions>
<execution>
<id>bnd-process</id>
<configuration>
<bnd>Fragment-Host: some-bsn</bnd>
</configuration>
</execution>
</executions>
</plugin>
The merging mechanism in Maven and Bnd differs! bnd-maven-plugin deliberately deviates from Maven standards to allow merging of bnd configurations (which wouldn't be possible in Maven). Therefore also the same kind of merging should happen on all levels.
- Parent POMs
- Plugin Mgmt -> Plugins
- Plugin -> Plugin Executions
Currently the bnd specific merging is only implemented for 2.
Currently the bnd specific merging is only implemented for 2.
bnd-maven already considers the parent pom so have you tried my suggestion?
parent pom is not correctly considered: for example having multiple parent levels with each having bnd plugin parameter will just be merged by Maven logic, i.e. just one value wins. It is not merged one level below (within the bnd instructions)!
Can you probably give a runnable example (or even better, provide a testcase here)?
Where are we on this? Anybody going to make a PR?
Yes, I will look into this, but it will take some time.
@kwin any update?