0

亲爱的 StackOverflow 用户,

我想将我用 SmartGWT 编写的、由 maven 编译的巨大应用程序拆分为几个子项目,例如:common、custom-widgets、forms、custom-datasources、sites。

主要思想是:一旦子项目被 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>
4

1 回答 1

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>

基于此文件:

于 2013-02-16T10:49:33.437 回答