2

私は、単純な Java アプリケーション (maven-archetype-quickstart で生成) と GWT アプリケーション (gwt-maven-plugin で生成) の 2 つの Maven モジュールを含む親プロジェクトを持っています。

両方のモジュールの出力ディレクトリを親の /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

3 つの 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 に答える