开发者

How to generate two xmlbeans in one pom file

I tried to generate two xmlbeans in one project. Each one, for example, gets participant object, so I can't put them in one configuration. The way I did was using two excution, 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 is not working at all. Could anyone help me with that, thanks


Thanks everybody, i got the answer, the following pom is working 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>


This doesn't work because the id is only used to find an existing execution (when you want to tweak it).

Your problem is that Maven can't run the same plugin twice in the same phase.

What are your options?

  1. Split that into different sub modules

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

But I wonder why you can't use two xmlConfig elements. Just put all your .xsd files into one directory and create as many beans from them as necessary (see "Multiple XSDConfig Directories")


You should try using another, distinct phase for the second invocation. AFAIK the same plugin cannot be executed twice in the same lifecycle phase.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜