亲爱的StackOverflow用户,
我想将由maven编译的SmartGWT编写的巨大应用程序拆分为多个子项目,例如: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>
答案 0 :(得分: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>
基于这些文件: