Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I export all the generated with cxg-codegen-plugin classes from a Java 9 module?

I've got a module without any explicit sources. This module contains the following cxf-codegen-plugin configuration:

    <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>
                                    ${project.build.directory}/schema/wsdl/service.wsdl
                                </wsdl>
                                <bindingFiles>
                                    <bindingFile>
                                        ${basedir}/src/main/resources/bindings.xml
                                    </bindingFile>
                                </bindingFiles>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

So it is a dependency with generated classes. I need to export all the classes to other Java modules. Let's say, I need to export com.company.team.app package. I tried adding it to module-info.java but it doesn't compile because it says (which is valid actually):

module-info.java:[6,20] package is empty or does not exist: com.company.team.app

How do I export this classes then? Thank you very much!

like image 632
Dmitry Senkovich Avatar asked Sep 03 '26 11:09

Dmitry Senkovich


1 Answers

The compile phase comes after generate-sources, so unless you see that error message before the compile phase (that would be weird!), the sources are already generated.

Here's what I would do in your situation:

  • Make sure the sources are actually generated. ~> Do you see them in the file system after mvn clean compile?
  • Make sure the folder is included in the sources to compile. ~> Run mvn compile -X and look out for the message block starting with "Source roots" - the folder needs to be mentioned there. (If it is not, add it.)
  • Make sure the package name is correct, i.e. the generated package names and the exported package name must be identical.
like image 125
Nicolai Parlog Avatar answered Sep 05 '26 00:09

Nicolai Parlog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!