Maven GWT plugin adding other source directories

泪湿孤枕 提交于 2019-12-24 04:50:07

问题


How do I add another source directory to the maven gwt compile plugin? I have some generated code that I need to include in the compile.

If I can't, what do people suggest to get around this?


回答1:


I don't know if you have looked into this, but you could use the compileSourcesArtifacts attribute to include your generated code as an external library. There is an article on setting this up in the GWT Plugin Documentation. However, this will only work if you don't need the external code to be included with your web app.

Whenever we needed to do this in the past, we used the maven-resources-plugin's copy-resources goal to copy the source code into our main package structure, and configured the maven-clean-plugin to remove the files. Because the gwt compile happens during the prepare-package phase of the build lifecycle, you would need to copy your source files into the directory before that (we bound ours to process-classes).




回答2:


I put the i18n goal at the generate-resourcces phase and it worked well. It will be executed before the gwt compile.

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


This works because your generated output is generated in the normal source folder. But the question was how to add an extra source folder.



来源:https://stackoverflow.com/questions/6512638/maven-gwt-plugin-adding-other-source-directories

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!