maven-gwt-plugin 并打包到 JAR

标签 maven gwt maven-jar-plugin

我正在将遗留的 Spring 项目构建脚本从 Ant 重写为 Maven。该项目有几个 GWT 模块,每个模块都编译为 JAR。当前的项目结构由几个Maven模块组成,或多或少是这样的: mainProject |- AnalyzerGWT <-- this module uses GWT |- analyzer <-- this doesn't |- someOtherModule |- p4you-spring <-- this module has resources and builds WAR

每个使用 GWT 的模块在其 pom.xml 中都有以下代码(模块称为 AnalyzerGWT):

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
                <compileSourcesArtifacts>
                    <artifact>com.pamm:portal-common</artifact>
                    <artifact>com.pamm:analyzer</artifact>
                </compileSourcesArtifacts>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

编译成功,结果 GWT 资源保存到AnalyzerGWT/target/AnalyzerGWT-1.0/com.pamm.analyzer.gwt.Analyzer/,但是该目录的内容不包含在结果中JAR 文件。

有没有一种优雅的方法可以将此目录的内容复制到 JAR 的根路径中?

最佳答案

我通过添加以下内容成功解决了该问题:

   <plugin>       
         <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                        <resources>
                            <resource>
                                <directory>
                                    ${project.build.directory}/AnalyzerGWT-1.0/com.pamm.analyzer.gwt.Analyzer/
                                </directory>
                                <filtering>false</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
    </plugin>

<plugins> pom.xml 中的部分。

关于maven-gwt-plugin 并打包到 JAR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33610920/

相关文章:

java - 我必须在 GWT 项目中更改什么才能使其成为 "module"

maven-javadoc-plugin 覆盖中央存储库

java - Maven:在 JAR 的 META-INF 中包含文件

java - Gwt Maven 多模块。如何配置依赖项以将请求工厂代理放入共享模块中?

java - GWT、Maven 和 AspectJ : RequestFactory validation for AOPed code?

maven - 为什么 Maven JAR 插件不包含某些资源?

maven - Jenkins 和 maven-buildnumber-plugin

java - 如何将 Tycho 包装类型添加到 Eclipse 中的 Maven 对话框中?

web-applications - Maven 对 Web 应用程序的依赖

java - android studio 构建失败,因为 "Cannot cast object ' 1 1' with class ' java.lang.Integer' to class "