[ 
https://issues.apache.org/jira/browse/CXF-9288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154089#comment-18154089
 ] 

Freeman Yue Fang commented on CXF-9288:
---------------------------------------

+1, this would be a useful addition. XJC already scans any *.jar given as a 
plain argument for META-INF/sun-jaxb.episode (Options.scanEpisodeFile), and 
wsdl2java passes -xjc arguments through to XJC. So today 
`<extraarg>-xjc/path/to/common.jar</extraarg>` (or -b with the episode file) 
already skips the shared classes. The new option could just add the resolved 
dependency jars that contain META-INF/sun-jaxb.episode as XJC arguments; 
there's no need to extract the files. The mojo already resolves dependencies.

Suggestions: keep it to META-INF/sun-jaxb.episode (what XJC reads), include 
provided scope, make it available per wsdlOption too, and document that an 
episode marks the whole namespace as already generated (map="false"). Please go 
ahead with a PR. Thanks!

> 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
>
> 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)

Reply via email to