2

我有一个带有 2 个 maven 模块的父项目,一个简单的 Java 应用程序(使用 maven-archetype-quickstart 生成)和一个 GWT 应用程序(使用 gwt-maven-plugin 生成)。

我正在尝试将两个模块的输出目录设置为父 /target/ 文件夹,但是当应用程序编译没有错误时,当我尝试在 tomcat [with mvn tomcat:run] 中运行它时,我收到以下错误:

[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
javac: directory not found: /null/null/WEB-INF/lib
Usage: javac <options> <source files>
use -help for a list of possible options

三个 pom.xml 文件如下:

父 POM

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>gr.veltisto</groupId>
    <artifactId>ennovation</artifactId>
    <version>0.1.1</version>
    <packaging>pom</packaging>      

    <modules>
        <module>core</module>
        <module>gwt</module>
    </modules>
</project>

java模块POM

<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>gr.veltisto.ennovation</groupId>
<artifactId>core</artifactId>
<version>0.1.1</version>
<packaging>jar</packaging>
<name>Veltisto Core Maven Module</name> 

<parent>
    <groupId>gr.veltisto</groupId>
    <artifactId>ennovation</artifactId>
    <version>0.1.1</version>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    (...)
</dependencies>

<build>
    <outputDirectory>/${project.parent.build.directory}/${project.parent.build.finalName}/WEB-INF/lib</outputDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <compilerVersion>1.6</compilerVersion>
            </configuration>
        </plugin>
    </plugins>
</build>

GWT 模块 POM

<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/maven-v4_0_0.xsd">

<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>gr.veltisto.ennovation</groupId>
<artifactId>gwt</artifactId>
<packaging>war</packaging>
<version>0.0.1</version>
<name>Veltisto GWT Maven Module</name>

<parent>
    <groupId>gr.veltisto</groupId>
    <artifactId>ennovation</artifactId>
    <version>0.1.1</version>
</parent>

<properties>
    <!-- Convenience property to set the GWT version -->
    <gwtVersion>2.5.0-rc1</gwtVersion>
    <!-- GWT needs at least java 1.5 -->
    <webappDirectory>/${project.parent.build.directory}/${project.parent.build.finalName}</webappDirectory>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>${gwtVersion}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwtVersion}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <classifier>sources</classifier>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.github.gwtbootstrap</groupId>
        <artifactId>gwt-bootstrap</artifactId>
        <version>2.0.4.0</version>
    </dependency>
</dependencies>

<build>
    <!-- Generate compiled stuff in the folder used for developing mode -->
    <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

    <plugins>

        <!-- GWT Maven Plugin -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>2.5.0-rc1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test</goal>
                        <goal>i18n</goal>
                        <goal>generateAsync</goal>
                    </goals>
                </execution>
            </executions>
            <!-- Plugin configuration. There are many available options, see gwt-maven-plugin 
                documentation at codehaus.org -->
            <configuration>
                <runTarget>gwt.html</runTarget>
                <hostedWebapp>${webappDirectory}</hostedWebapp>
                <i18nMessagesBundle>gr.veltisto.ennovation.client.Messages</i18nMessagesBundle>
            </configuration>
        </plugin>

        <!-- Copy static web files before executing gwt:run -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>exploded</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <webappDirectory>${webappDirectory}</webappDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
</build>

PS。当我运行时mvn compile,输出目录已正确创建。只有当我跑步时,我mvn tomcat:run才会得到/null/null/WEB-INF/lib参考

4

1 回答 1

4

不如将 GWT 模块用作 webapp 模块中的覆盖层?

请参阅https://github.com/tbroyer/gwt-maven-archetypes(我刚刚添加了 tomcat-maven-plugin 支持,有一些调整和解决方法可以使其工作)

于 2012-09-29T15:29:39.130 回答