How to generate two xmlbeans in one pom file

I tried to create two xmlbeans in one project. Each of them, for example, receives a member object, so I can not put them in one configuration. The way I did this is to use two options, here is my pom file:

            <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xmlbeans-maven-plugin</artifactId>
            <version>2.3.3</version>
            <executions>
                <execution>
                    <id>xmlbean1</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xmlbeans</goal>
                    </goals>
                    <configuration>
                        <xmlConfigs>
                            <xmlConfig implementation="java.io.File">src/main/xsdconfig/xmlbean1</xmlConfig>
                        </xmlConfigs>
                        <verbose>true</verbose>
                        <schemaDirectory>src/main/xsd/xmlbean1</schemaDirectory>
                    </configuration>
                </execution>
                <execution>
                    <id>xmlbean2</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xmlbeans</goal>
                    </goals>
                    <configuration>
                        <xmlConfigs>
                            <xmlConfig implementation="java.io.File">src/main/xsdconfig/xmlbean2</xmlConfig>
                        </xmlConfigs>
                        <verbose>true</verbose>
                        <schemaDirectory>src/main/xsd/xmlbean2</schemaDirectory>
                    </configuration>
                </execution>
            </executions>
            <inherited>true</inherited>
        </plugin>

But it doesn’t work at all. Can anyone help me on this, thanks

+5
source share
3 answers

Thanks everyone, I got the answer, the following pom works fine:

<executions>
                <execution>
                    <id>id1</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xmlbeans</goal>
                    </goals>
                    <configuration>
                        <schemaDirectory>src/main/xsd/first</schemaDirectory>
                        <xmlConfigs>
                            <xmlConfig implementation="java.io.File">src/main/xsdconfig/first</xmlConfig>
                        </xmlConfigs>
                        <verbose>true</verbose>
                        <sourceGenerationDirectory>target/first-resource</sourceGenerationDirectory>
                        <classGenerationDirectory>target/first-class</classGenerationDirectory>
                        <staleFile>target/first/first.stale</staleFile>
                    </configuration>
                </execution>
                <execution>
                    <id>id2</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xmlbeans</goal>
                    </goals>
                    <configuration>
                        <schemaDirectory>src/main/xsd/second</schemaDirectory>
                        <xmlConfigs>
                            <xmlConfig implementation="java.io.File">src/main/xsdconfig/second</xmlConfig>
                        </xmlConfigs>
                        <verbose>true</verbose>
                        <sourceGenerationDirectory>target/second-resource</sourceGenerationDirectory>
                        <classGenerationDirectory>target/second-class</classGenerationDirectory>
                        <staleFile>target/second/second.stale</staleFile>
                    </configuration>
                </execution>
            </executions>
+2
source

You should try using a different, different phase for the second call. AFAIK the same plugin cannot be executed twice in the same phase of the life cycle.

+1
source

, id ( ).

, Maven phase.

What are your options?

  • Divide it into different auxiliary modules

  • Use Ant to create xmlbeans and use the element antrun.

But I am wondering why you cannot use two elements xmlConfig. Just put all your files .xsdin one directory and create as many beans from them as possible (see " Multiple XSDConfig Directories ")

+1
source

All Articles