我有一个带有2个maven模块的父项目,一个简单的Java应用程序(使用maven-archetype-quickstart生成)和一个GWT应用程序(使用gwt-maven-plugin生成)。
我正在尝试将两个模块的输出目录设置为父/目标/文件夹,但是当应用程序编译时没有错误,当我尝试在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文件如下:
<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>
<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>
<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
参考
答案 0 :(得分:4)
如何将GWT模块用作webapp模块中的叠加层呢?
请参阅https://github.com/tbroyer/gwt-maven-archetypes(我刚刚添加了tomcat-maven-plugin支持,有一些调整和解决方法可以使其工作)