[YANGTOOLS-1457] yang-maven-plugin execution is not reliably following the configuration Created: 11/Oct/22  Updated: 18/Jan/24

Status: Confirmed
Project: yangtools
Component/s: maven plugin
Affects Version/s: 10.0.0
Fix Version/s: 14.0.0, 11.0.6, 13.0.2

Type: Bug Priority: Medium
Reporter: Ruslan Kashapov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
split from YANGTOOLS-747 Remove yang-maven-plugin-spi APIs Resolved

 Description   

Case #1

Actual: if multiple fileGenerator sections are using same identifier then only one will be processed, the others will be ignored. the issue is caused by configuration data transformation  from list to map, resulting part of configuration being lost

example (addresses org.opendaylight.yangtools.yang2sources.plugin.it.YangToSourcesPluginTestIT#testAdditionalConfiguration):

<plugin>
    <groupId>org.opendaylight.yangtools</groupId>
    <artifactId>yang-maven-plugin</artifactId>
    <version>${project.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>generate-sources</goal>
            </goals>
            <configuration>
                <yangFilesRootDir>../files</yangFilesRootDir>
                <inspectDependencies>false</inspectDependencies>
                <fileGenerators>
                    <fileGenerator>
                        <identifier>
                            org.opendaylight.yangtools.plugin.generator.api.TestFileGenerator
                        </identifier>
                        <configuration>
                            <nm1>abcd=a.b.c.d</nm1>
                            <nm2>abcd2=a.b.c.d.2</nm2>
                        </configuration>
                    </fileGenerator>
                    <fileGenerator>
                        <identifier>
                            org.opendaylight.yangtools.plugin.generator.api.TestFileGenerator
                        </identifier>
                        <configuration>
                            <c1>config</c1>
                        </configuration>
                    </fileGenerator>
                </fileGenerators>
            </configuration>
        </execution>
    </executions>
 ...
</plugin> 

Expected: it should be possible to execute same file generator

Case #2

Actual: The file generation is executed for every FileGeneratorFactory implementation found in the classpath even if the FileGenerator identifier is absent in the configuration.
The issue is caused by incorrect logic within
org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor#instantiateGenerators,
where the main condition is factory existence, fileGenerator configuration for associated identifier is optional

Expected: file generation should be executed only for explicitly defined generators.


Generated at Wed Feb 07 20:56:12 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.