2015-11-09 32 views
2

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

每个模块,其使用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 /目标/ AnalyzerGWT-1.0/com.pamm.analyzer.gwt.Analyzer/,不包括在此目录中,不过含量,从而导致JAR文件。

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

+0

我想你应该建立和安装这个GWT模块,然后在那里添加依赖关系在你的战争项目 – Ajax

回答

2

我设法通过加入要解决的问题:

<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

0

该文件夹中的文件是最有可能由GWT编译器产生的JavaScript,因此你可能会更好过包装模块作为一个WAR文件,而不是

<packaging>war</packaging> 

和Maven将完成剩下的为你。

干杯,

+0

谢谢你的回答。然而它并没有做到这一点。 项目有几个模块,每个模块都应该编译成JAR。所有这些JAR都由单独模块中定义的* maven-war-plugin *打包为WAR。结构或多或少是这样的: – yuiu

+0

我没有设法写5分钟:父项目:* mediaMonitor *,模块:* AnalyzerGWT *,*分析器*,一些其他模块,* p4you-spring * - 带有编译WAR的资源的模块。 – yuiu

+1

战争叠加如何? –