[
https://issues.apache.org/jira/browse/CXF-9288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154530#comment-18154530
]
Marco Semiao commented on CXF-9288:
-----------------------------------
Hi Freeman, thanks for your feedback.
I was thinking of following the example of jaxb2-maven-plugin, and that is what
I had started to do. But I understand your point: the META-INF/JAXB directory
is not a JAXB convention, it is specific to the jaxb2 plugin only.
I take note, you are right. We can do a first version as you suggest, limited
to META-INF/sun-jaxb.episode and passing the dependency JARs to XJC.
However, I do not agree on the provided scope. The purpose of this feature is
to pull in a dependency whose classes will be used instead of being generated.
This implies a regular dependency (compile or runtime), which rules out
provided. This is also what jaxb2-maven-plugin does, so I propose to stay with
compile and runtime.
I'm preparing the PR.
> Add automatic discovery of JAXB episode files from Maven dependencies
> (useDependenciesAsEpisodes)
> -------------------------------------------------------------------------------------------------
>
> Key: CXF-9288
> URL: https://issues.apache.org/jira/browse/CXF-9288
> Project: CXF
> Issue Type: Improvement
> Reporter: Marco Semiao
> Priority: Major
> Fix For: 4.3.0
>
>
> h3. Context / Problem
> In multi-module architectures where XSD schemas are shared across several
> projects, common JAXB classes are typically generated once in a dedicated
> Maven module (packaging a JAXB episode file) and imported as a dependency in
> downstream modules.
> Currently, when running {{wsdl2java}} via {{cxf-codegen-plugin}}, preventing
> the regeneration of these already-compiled classes requires manually
> declaring each episode file in the plugin configuration (via
> {{<bindingFiles>}} or {{<extraargs>}}), which becomes verbose and error-prone
> as the number of shared dependencies grows.
> h3. Proposed Feature
> Add an opt-in configuration parameter {{<useDependenciesAsEpisodes>}}
> (boolean, {{false}} by default to preserve backward compatibility), inspired
> by {{org.codehaus.mojo:jaxb2-maven-plugin}} (since version 4.1.1) and
> {{jaxb-tools}}.
> When {{<useDependenciesAsEpisodes>true</useDependenciesAsEpisodes>}} is
> enabled:
> # The plugin scans direct Maven project dependencies in {{compile}} and
> {{runtime}} scopes (optionally paired with
> {{<includeTransitiveEpisodes>false</includeTransitiveEpisodes>}}).
> # For each dependency JAR, it looks for a JAXB episode resource following
> standard conventions:
> #* {{META-INF/sun-jaxb.episode}}
> #* {{META-INF/JAXB/*.xjb}}
> # Discovered episode files are extracted (e.g., under
> {{${project.build.directory}/cxf-episodes/}}) and automatically passed as
> external binding files to XJC during {{wsdl2java}} execution.
> h3. Example Configuration
> {code:xml}
> <plugin>
> <groupId>org.apache.cxf</groupId>
> <artifactId>cxf-codegen-plugin</artifactId>
> <version>${cxf.version}</version>
> <configuration>
> <useDependenciesAsEpisodes>true</useDependenciesAsEpisodes>
> </configuration>
> <executions>
> <execution>
> <id>generate-sources</id>
> <phase>generate-sources</phase>
> <goals>
> <goal>wsdl2java</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> {code}
> h3. Expected Benefits
> * Greatly simplifies Maven configuration in projects sharing common XSD data
> models.
> * Avoids duplicate generated classes and classpath conflicts.
> * Aligns {{cxf-codegen-plugin}} with standard episode handling in other Maven
> JAXB plugins.
> h3. Contribution Offer
> Before starting implementation, I would like to check if the community and
> maintainers are interested in adding this feature to {{cxf-codegen-plugin}}.
> If there is interest and agreement on the approach, I would be happy to
> implement it and submit a Pull Request.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)