javamavenxmlbeanswsdl2codexmlbeans-maven-plugin

No XMLBean Classes Generated for XSD and WSDL Files (Maven)


I ma trying to generate XMLBean classes for some XSD and WSDL that I have. My POM file looks like:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>MySchemaFiles</groupId>
    <artifactId>MySchemaFiles</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>MySchemaFiles</name>
    <url>http://maven.apache.org</url>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>3.0.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/xmlbeans-maven-plugin -->
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xmlbeans-maven-plugin</artifactId>
            <version>2.3.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-wsdl2code-maven-plugin -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.7.9</version>
        </dependency>

    </dependencies>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
    </properties>

    <build>
        <pluginManagement>

            <plugins>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>xmlbeans-maven-plugin</artifactId>
                    <version>2.3.3</version>
                    <dependencies>
                        <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/xmlbeans-maven-plugin -->
                        <dependency>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>xmlbeans-maven-plugin</artifactId>
                            <version>2.3.3</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <schemaDirectory>${basedir}/src/main/resources/XSDFiles/</schemaDirectory>
                        <generatedSchemaDirectory>${basedir}/src/main/java/</generatedSchemaDirectory>
                        <outputJar>MySchemaFiles.jar</outputJar>
                        <classGenerationDirectory>${basedir}/target/java/classes/</classGenerationDirectory>
                        <verbose>true</verbose>
                        <sourceGenerationDirectory>${basedir}/src/main/java/</sourceGenerationDirectory>
                    </configuration>

                    <executions>

                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>xmlbeans</goal>
                            </goals>
                            <configuration>
                                <quiet>false</quiet>
                                <staleFile>${basedir}/src/main/resources/target/staleFile/</staleFile>
                                <schemaDirectory>${basedir}/src/main/resources/XSDFiles/</schemaDirectory>
                                <sourceGenerationDirectory>${basedir}/src/main/java/</sourceGenerationDirectory>
                                <classGenerationDirectory>${basedir}/target/java/classes/</classGenerationDirectory>
                                <compiler>1.8</compiler>
                            </configuration>
                            <inherited>true</inherited>
                        </execution>

                    </executions>

                </plugin>

                <plugin>
                    <groupId>org.apache.axis2</groupId>
                    <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                    <version>1.7.9</version>
                    <dependencies>
                        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-wsdl2code-maven-plugin -->
                        <dependency>
                            <groupId>org.apache.axis2</groupId>
                            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                            <version>1.7.9</version>
                        </dependency>
                    </dependencies>

                    <executions>

                        <execution>
                            <id>genrate-wsdl-to-java</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>wsdl2code</goal>
                            </goals>
                            <configuration>
                                <resources>
                                    <resource>
                                        <filtering>false</filtering>
                                        <directory>${basedir}/src/main/resources/WSDLFiles/</directory>
                                    </resource>
                                </resources>
                                <wsdlFile>${basedir}/src/main/resources/WSDLFiles/AtcProcessOrder.wsdl</wsdlFile>
                                <generateServerSide>false</generateServerSide>
                                <databindingName>xmlbeans</databindingName>
                                <outputDirectory>${basedir}/src/main/java/</outputDirectory>
                                <overWrite>true</overWrite>
                                <packageName>com.att.logicalprovisioning.atc.processorder</packageName>
                                <unpackClasses>true</unpackClasses>
                            </configuration>
                            <inherited>true</inherited>
                        </execution>

                    </executions>

                </plugin>

            </plugins>

        </pluginManagement>

    </build>

</project>

When I run:

mvn clean package -X

I do not see any errors, or at least nothing catches my eye, but there are absolutely no java classes generated. I trying to figure out what the problem is, but haven't been able to because of the lack of examples/documentations. I can switch to JAXB, but that is not an option. I have to stick to XMLBeans.


Solution

  • You only configured the plugins in <pluginManagement>. You need to also declare them in the <plugins> section (outside pluginManagement) so that they become part of your build.