【问题标题】:Maven GWT plugin adding other source directoriesMaven GWT 插件添加其他源目录
【发布时间】:2011-06-28 20:23:20
【问题描述】:

如何将另一个源目录添加到 maven gwt 编译插件?我有一些生成的代码需要包含在编译中。

如果我不能,人们建议如何解决这个问题?

【问题讨论】:

    标签: gwt plugins maven


    【解决方案1】:

    我不知道您是否对此进行了研究,但您可以使用compileSourcesArtifacts 属性将您生成的代码作为外部库包含在内。 GWT Plugin Documentation 中有一篇关于设置的文章。但是,这仅在您不需要将外部代码包含在您的网络应用程序中时才有效。

    过去每当我们需要这样做时,我们都会使用maven-resources-plugin's copy-resources goal 将源代码复制到我们的主包结构中,并配置maven-clean-plugin to remove the files。由于 gwt 编译发生在 build lifecycleprepare-package 阶段,因此您需要将源文件复制到之前的目录中(我们绑定到 process-classes)。

    【讨论】:

    • 我应该将其他源文件复制到哪个目录以便 gwt compile 获取?
    • 我需要更多地了解你想用它们做什么。它们是视图、演示者、库类、模型还是其他?
    • 它们是生成的工件、gwtp 事件和操作。然而事实证明,只要我在 gwt:compile 之前进行 java 编译,我就可以了(一旦我完成了它就可以了)。不需要这么复杂的解决方案。
    【解决方案2】:

    我将 i18n 目标放在生成资源阶段,它运行良好。它将在 gwt 编译之前执行。

        <plugins>
            <!-- GWT Maven Plugin-->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.5.0-rc1</version>
                 <dependencies>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-user</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-dev</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-servlet</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                </dependencies>
    
                <executions>
                    **<execution>
                        <id>generate-i18n</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>i18n</goal>
                        </goals>
                    </execution>**
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>resources</goal>
                            <goal>compile</goal>
                            <goal>test</goal>
                            <goal>generateAsync</goal>
                        </goals>
                    </execution>
    
                </executions>
    
                <configuration>
                        <!-- your config -->
                </configuration>
            </plugin>
    

    【讨论】:

      【解决方案3】:

      这是有效的,因为您生成的输出是在正常的源文件夹中生成的。 但问题是如何添加额外的源文件夹。

      【讨论】:

        猜你喜欢
        • 2010-11-09
        • 2011-02-28
        • 1970-01-01
        • 2012-04-24
        • 2015-03-13
        • 2011-09-16
        • 1970-01-01
        • 1970-01-01
        • 2019-07-28
        相关资源
        最近更新 更多