我正在尝试将一个工作的单个 GWT 项目转换为几个 Maven 模块。新结构应如下所示:
Project
|- pom.xml
|- Project-Common(only Common-Classes)
|--- pom.xml
|--- Packaging: jar
|- Project-War(includes *gwt.xml)
|--- pom.xml
|--- Packaging: war
我的文件看起来像这样(许多依赖项,我想我删除了不必要的内容以使我的问题更清楚)项目 pom.xml:
<modelVersion>4.0.0</modelVersion>
<artifactId>project</artifactId>
<packaging>pom</packaging>
<name>Project - Modules</name>
<version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>com.project</groupId>
<artifactId>project-parent-parent</artifactId>
<version>2.0.0</version>
<relativePath />
</parent>
<modules>
<module>/project-war</module>
<module>/project-common</module>
</modules>
项目-Common pom.xml:
<modelVersion>4.0.0</modelVersion>
<artifactId>project-common</artifactId>
<packaging>jar</packaging>
<name>Project - Common</name>
<version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>com.project</groupId>
<artifactId>project-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath />
</parent>
<build>
<plugins>
<plugin>
<groupId>com.github.koraktor</groupId>
<artifactId>mavanagaiata</artifactId>
<executions>
<execution>
<id>load-git-branch</id>
<phase>validate</phase>
<goals>
<goal>commit</goal>
</goals>
<configuration>
<dirtyFlag>*</dirtyFlag>
<gitDir>../../.git</gitDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
项目战争 pom.xml:
<modelVersion>4.0.0</modelVersion>
<artifactId>project-war</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Project - WAR</name>
<parent>
<groupId>com.project</groupId>
<artifactId>parent-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.project</groupId>
<artifactId>project-common</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<inherited>true</inherited>
<configuration>
<runTarget>/test.html</runTarget>
<modules>
<module>com.project.modules.Test</module>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<id>VerifyRequestFactoryInterfaces</id>
<executable>java</executable>
<arguments>
<argument>-cp</argument>
<classpath />
<argument>com.google.web.bindery.requestfactory.apt.ValidationTool</argument>
<argument>${project.build.outputDirectory}</argument>
<argument>com.project.factorys.TestRequestFactory</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>src/main</directory>
<includes>
<directory>gwt-unitCache/**</directory>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>com.github.koraktor</groupId>
<artifactId>mavanagaiata</artifactId>
<executions>
<execution>
<id>load-git-branch</id>
<phase>validate</phase>
<goals>
<goal>commit</goal>
</goals>
<configuration>
<dirtyFlag>*</dirtyFlag>
<gitDir>../../.git</gitDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
旧项目在我的 Project-War 中,我添加了 Project & Project-Common。在此设置中,项目构建,我得到“新的” Project-War.war 。但是,当我将 ErrorCode.java 从 Project-War 移动到 Project-Common 时,出现以下错误:
[INFO] 跟踪类型“com.project.modules.TestViewImpl”的编译失败路径 [INFO] [错误] '.../project/project-war/src/main/java/com/project/modules/TestViewImpl 中的错误.java' [INFO] [ERROR] Line 20: No source code is available for type com.project.errorcodes.ErrorCode; 你忘了继承一个必需的模块吗?[INFO] [ERROR] 提示:检查模块的继承链;它可能没有继承所需的模块,或者模块可能没有正确添加其源路径条目