2013-02-15 68 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> 

基於此文件: