简体   繁体   English

如何在一个pom文件中生成两个xmlbeans

[英]How to generate two xmlbeans in one pom file

I tried to generate two xmlbeans in one project.我试图在一个项目中生成两个 xmlbean。 Each one, for example, gets participant object, so I can't put them in one configuration.例如,每一个都有参与者 object,所以我不能将它们放在一个配置中。 The way I did was using two excution, here is my pom file:我所做的方式是使用两个执行,这是我的 pom 文件:

            <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:谢谢大家,我得到了答案,以下pom工作正常:

<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>

You should try using another, distinct phase for the second invocation.您应该尝试使用另一个不同的阶段进行第二次调用。 AFAIK the same plugin cannot be executed twice in the same lifecycle phase. AFAIK 同一个插件不能在同一个生命周期阶段执行两次。

This doesn't work because the id is only used to find an existing execution (when you want to tweak it).这不起作用,因为id仅用于查找现有执行(当您想要调整它时)。

Your problem is that Maven can't run the same plugin twice in the same phase .你的问题是 Maven 不能在同一phase运行同一个插件两次。

What are your options?你有什么选择?

  1. Split that into different sub modules将其拆分为不同的子模块

  2. Use Ant to create xmlbeans and use the antrun element.使用 Ant 创建 xmlbeans 并使用antrun元素。

But I wonder why you can't use two xmlConfig elements.但我想知道为什么你不能使用两个xmlConfig元素。 Just put all your .xsd files into one directory and create as many beans from them as necessary (see " Multiple XSDConfig Directories ")只需将所有.xsd文件放入一个目录并根据需要从它们创建尽可能多的 bean(请参阅“多个 XSDConfig 目录”)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM