【问题标题】:Multi-module Maven POM多模块 Maven POM
【发布时间】:2012-09-29 15:09:04
【问题描述】:

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

我正在尝试将两个模块的输出目录设置为父 /target/ 文件夹,但是当应用程序编译没有错误时,当我尝试在 tomcat [使用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 参考

【问题讨论】:

    标签: gwt maven pom.xml


    【解决方案1】:

    将您的 GWT 模块用作 webapp 模块中的覆盖如何?

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

    【讨论】:

    • 我会等待你的提交,一定会尝试的
    • 我刚刚推送了提交。试用并报告问题(如果有)。
    • 目前我们已经将这两个模块拆分为两个不同的 maven 项目,稍后我们将尝试将它们与此原型集成
    猜你喜欢
    • 2012-04-27
    • 2013-02-23
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 2020-06-27
    • 1970-01-01
    • 2012-02-06
    相关资源
    最近更新 更多