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

Dmitry Senkovich :

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!

Nicolai :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=104537&siteId=1