2013-02-15 51 views
0

亲爱的StackOverflow用户,Maven的GWT(SmartGWT的):如何组织我的项目,以防止长编译

我想拆我的巨大的应用写在SmartGWT的,由行家编译成几个子项目,例如:普通,自定义小部件,窗体,自定义数据源,站点。

其主要思想是:一旦子项目被GWT编译,可以方便地在其他子项目中使用,以再次跳过编译。 (对不起,我的英语,但我觉得你让我点)

例如子项目pom.xml是:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <groupId>eu.nanobeauty</groupId> 
     <artifactId>nanobeauty</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <artifactId>common</artifactId> 
    <packaging>jar</packaging> 
    <name>nanoBeauty :: Common</name> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>gwt-maven-plugin</artifactId> 
       <version>${gwt.version}</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

Common.gwt.xml是:

<module> 
    <inherits name="com.google.gwt.user.User"/> 
    <inherits name="com.smartgwt.SmartGwtNoTheme"/> 
    <source path="common"/> 
</module> 

和家长pom.xml是:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>eu.nanobeauty</groupId> 
    <artifactId>nanobeauty</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <name>nanoBeauty :: Parent</name> 

    <modules> 
     <module>datasources</module> 
     <!-- multimodule : each form different project --> 
     <module>forms</module> 
     <!-- multimodule : each site different project --> 
     <module>sites</module> 
     <module>common</module> 
    </modules> 

    <properties> 
     <gwt.version>2.5.0</gwt.version> 
     <smartgwt.version>3.1</smartgwt.version> 
     <java.version>1.6</java.version> 
     <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.war.plugin.version>2.1.1</maven.war.plugin.version> 
    </properties> 

    <repositories> 
     <repository> 
      <id>smartclient</id> 
      <url>http://smartclient.com/maven2</url> 
     </repository> 
    </repositories> 

    <dependencies> 
     <dependency> 
      <groupId>com.smartgwt</groupId> 
      <artifactId>smartgwt</artifactId> 
      <version>${smartgwt.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.gwt</groupId> 
      <artifactId>gwt-servlet</artifactId> 
      <version>${gwt.version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.google.gwt</groupId> 
      <artifactId>gwt-user</artifactId> 
      <version>${gwt.version}</version> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>${java.version}</source> 
        <target>${java.version}</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

回答

0

经过漫长的夜间搜索,我发现解决方案:

它不能这样做,我想实现。

GWT需要源文件来生成JS文件。主模块pom.xml没问题,上面的例子.gwt.xml也可以。只有在子模块pom.xml文件中更改的唯一目标是resources

所以对于每个子模块我需要设置pom.xml看起来像类似于:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <groupId>eu.nanobeauty</groupId> 
     <artifactId>nanobeauty</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <artifactId>common</artifactId> 
    <packaging>jar</packaging> 
    <name>nanoBeauty :: Common</name> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>gwt-maven-plugin</artifactId> 
       <version>${gwt.version}</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>resources</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

基于此文件: