Maven GWT 编译器编译两次?
Maven GWT compiler compiling twice?
我是 maven pom 配置的新手,被这个案例困住了。我用谷歌搜索并 'Whosebuged' 寻找答案,但我看到的解决方案对我不起作用。
我在 Eclipse Mars 中有以下项目结构:
parent project(folder)
....pom.xml
....ear project(folder)
.......pom.xml
....rest project(war)(folder)
........pom.xml
....front project(war)(folder)
........pom.xml
当我执行 maven clean install -e wildfly:deploy
时,我将客户端(前端)项目编译了两次。我做错了什么?
其pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>parent</artifactId>
<groupId>com</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>client</artifactId>
<packaging>war</packaging>
<name>client</name>
<properties>
<version.com.google.gwt>2.7.0</version.com.google.gwt>
<version.org.codehaus.mojo.gwt.maven.plugin>2.7.0</version.org.codehaus.mojo.gwt.maven.plugin>
</properties>
<repositories>
<repository>
<id>redhat-techpreview-all-repository</id>
<url>https://maven.repository.redhat.com/techpreview/all/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>redhat-techpreview-all-repository</id>
<url>https://maven.repository.redhat.com/techpreview/all/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<!-- Google Web Toolkit (GWT) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${version.com.google.gwt}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${version.com.google.gwt}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${version.com.google.gwt}</version>
</dependency>
<dependency>
<groupId>com.googlecode.mgwt</groupId>
<artifactId>mgwt</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.gwtphonegap</groupId>
<artifactId>gwtphonegap</artifactId>
<version>3.5.0.1</version>
</dependency>
<dependency>
<groupId>com.allen-sauer.gwt.log</groupId>
<artifactId>gwt-log</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies>
<build>
<!-- Maven will append the version to the finalName (which is the name
given to the generated war, and hence the context root) -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>**/client/local/**/*.class</packagingExcludes>
</configuration>
</plugin>
<!-- GWT plugin to compile client-side java code to javascript and
to run GWT development mode -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${version.org.codehaus.mojo.gwt.maven.plugin}</version>
<configuration>
<inplace>true</inplace>
<logLevel>INFO</logLevel>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
<!-- Configure GWT's development mode (formerly known as hosted
mode) to not start the default server (embedded jetty), but to download the
HTML host page from the configured runTarget. -->
<noServer>true</noServer>
<runTarget>http://localhost:8080/client/index.html</runTarget>
<!-- <skip>true</skip> -->
</configuration>
<executions>
<execution>
<id>gwt-compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>gwt-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'deployments'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
和parent的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<name>parent</name>
<description>Main parent project</description>
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>client</module>
<module>projectEar</module>
<module>server</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- JBoss dependency versions -->
<version.wildfly.maven.plugin>1.1.0.Alpha5</version.wildfly.maven.plugin>
<version.jboss.maven.plugin>7.7.Final</version.jboss.maven.plugin>
<!-- Define the version of the JBoss BOMs we want to import to specify tested stacks. -->
<version.jboss.bom>8.2.2.Final</version.jboss.bom>
<version.wildfly>9.0.2.Final</version.wildfly>
<!-- other plugin versions -->
<version.compiler.plugin>3.1</version.compiler.plugin>
<version.ear.plugin>2.10.1</version.ear.plugin>
<version.ejb.plugin>2.5.1</version.ejb.plugin>
<version.surefire.plugin>2.16</version.surefire.plugin>
<version.war.plugin>2.6</version.war.plugin>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
<dependencyManagement>
<dependencies>
<!-- REST Services WAR -->
<dependency>
<groupId>com</groupId>
<artifactId>server</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<!-- GWT WAR -->
<dependency>
<groupId>com</groupId>
<artifactId>client</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<!-- The WildFly plugin deploys your ear to a local JBoss
AS container -->
<!-- Due to Maven's lack of intelligence with EARs we need
to configure the wildfly maven plugin to skip deployment for all modules.
We then enable it specifically in the ear module. -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<inherited>true</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
最后,EARs pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<name>pEAR</name>
<description>ear module</description>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent</artifactId>
<groupId>com</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>projectEar</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com</groupId>
<artifactId>server</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>client</artifactId>
<type>war</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<!-- Tell Maven we are using Java EE 7 -->
<version>7</version>
<!-- Use Java EE ear libraries as needed. Java EE ear libraries
are in easy way to package any libraries needed in the ear, and automatically
have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<fileNameMapping>no-version</fileNameMapping>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<filename>${project.artifactId}.ear</filename>
<skip>false</skip>
<home>C:\Develop\wildfly9</home>
<hostname>127.0.0.1</hostname>
<port>9990</port>
<username>admin</username>
<password>password</password>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app will need. -->
<!-- By default that is to put the resulting archive into the 'deployments' folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
如果您需要更多信息,请询问。我真的坚持这个,我很确定这完全是一个菜鸟失败。
最后通过更改执行maven命令解决了,我的意思是:
我是这样通过 eclipse 启动 Maven 的:
mvn clean install -e wildfly:deploy
现在,在改变这个之后..
mvn clean -e wildfly:deploy
根据 documentation,此插件中的 "deploy" 阶段调用 "package" 阶段:
Invokes the execution of the lifecycle phase package prior to executing itself.
另一种解决方案,使用第一个maven命令行是:
mvn clean install -e wildfly:deploy-only
避免 "package" 阶段。更多信息 aboy
感谢您的回答!
我是 maven pom 配置的新手,被这个案例困住了。我用谷歌搜索并 'Whosebuged' 寻找答案,但我看到的解决方案对我不起作用。
我在 Eclipse Mars 中有以下项目结构:
parent project(folder)
....pom.xml
....ear project(folder)
.......pom.xml
....rest project(war)(folder)
........pom.xml
....front project(war)(folder)
........pom.xml
当我执行 maven clean install -e wildfly:deploy
时,我将客户端(前端)项目编译了两次。我做错了什么?
其pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>parent</artifactId>
<groupId>com</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>client</artifactId>
<packaging>war</packaging>
<name>client</name>
<properties>
<version.com.google.gwt>2.7.0</version.com.google.gwt>
<version.org.codehaus.mojo.gwt.maven.plugin>2.7.0</version.org.codehaus.mojo.gwt.maven.plugin>
</properties>
<repositories>
<repository>
<id>redhat-techpreview-all-repository</id>
<url>https://maven.repository.redhat.com/techpreview/all/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>redhat-techpreview-all-repository</id>
<url>https://maven.repository.redhat.com/techpreview/all/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<!-- Google Web Toolkit (GWT) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${version.com.google.gwt}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${version.com.google.gwt}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${version.com.google.gwt}</version>
</dependency>
<dependency>
<groupId>com.googlecode.mgwt</groupId>
<artifactId>mgwt</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.gwtphonegap</groupId>
<artifactId>gwtphonegap</artifactId>
<version>3.5.0.1</version>
</dependency>
<dependency>
<groupId>com.allen-sauer.gwt.log</groupId>
<artifactId>gwt-log</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies>
<build>
<!-- Maven will append the version to the finalName (which is the name
given to the generated war, and hence the context root) -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>**/client/local/**/*.class</packagingExcludes>
</configuration>
</plugin>
<!-- GWT plugin to compile client-side java code to javascript and
to run GWT development mode -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${version.org.codehaus.mojo.gwt.maven.plugin}</version>
<configuration>
<inplace>true</inplace>
<logLevel>INFO</logLevel>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
<!-- Configure GWT's development mode (formerly known as hosted
mode) to not start the default server (embedded jetty), but to download the
HTML host page from the configured runTarget. -->
<noServer>true</noServer>
<runTarget>http://localhost:8080/client/index.html</runTarget>
<!-- <skip>true</skip> -->
</configuration>
<executions>
<execution>
<id>gwt-compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>gwt-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'deployments'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
和parent的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<name>parent</name>
<description>Main parent project</description>
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>client</module>
<module>projectEar</module>
<module>server</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- JBoss dependency versions -->
<version.wildfly.maven.plugin>1.1.0.Alpha5</version.wildfly.maven.plugin>
<version.jboss.maven.plugin>7.7.Final</version.jboss.maven.plugin>
<!-- Define the version of the JBoss BOMs we want to import to specify tested stacks. -->
<version.jboss.bom>8.2.2.Final</version.jboss.bom>
<version.wildfly>9.0.2.Final</version.wildfly>
<!-- other plugin versions -->
<version.compiler.plugin>3.1</version.compiler.plugin>
<version.ear.plugin>2.10.1</version.ear.plugin>
<version.ejb.plugin>2.5.1</version.ejb.plugin>
<version.surefire.plugin>2.16</version.surefire.plugin>
<version.war.plugin>2.6</version.war.plugin>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
<dependencyManagement>
<dependencies>
<!-- REST Services WAR -->
<dependency>
<groupId>com</groupId>
<artifactId>server</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<!-- GWT WAR -->
<dependency>
<groupId>com</groupId>
<artifactId>client</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<!-- The WildFly plugin deploys your ear to a local JBoss
AS container -->
<!-- Due to Maven's lack of intelligence with EARs we need
to configure the wildfly maven plugin to skip deployment for all modules.
We then enable it specifically in the ear module. -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<inherited>true</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
最后,EARs pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<name>pEAR</name>
<description>ear module</description>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent</artifactId>
<groupId>com</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>projectEar</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com</groupId>
<artifactId>server</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>client</artifactId>
<type>war</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<!-- Tell Maven we are using Java EE 7 -->
<version>7</version>
<!-- Use Java EE ear libraries as needed. Java EE ear libraries
are in easy way to package any libraries needed in the ear, and automatically
have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<fileNameMapping>no-version</fileNameMapping>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<filename>${project.artifactId}.ear</filename>
<skip>false</skip>
<home>C:\Develop\wildfly9</home>
<hostname>127.0.0.1</hostname>
<port>9990</port>
<username>admin</username>
<password>password</password>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app will need. -->
<!-- By default that is to put the resulting archive into the 'deployments' folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
如果您需要更多信息,请询问。我真的坚持这个,我很确定这完全是一个菜鸟失败。
最后通过更改执行maven命令解决了,我的意思是:
我是这样通过 eclipse 启动 Maven 的:
mvn clean install -e wildfly:deploy
现在,在改变这个之后..
mvn clean -e wildfly:deploy
根据 documentation,此插件中的 "deploy" 阶段调用 "package" 阶段:
Invokes the execution of the lifecycle phase package prior to executing itself.
另一种解决方案,使用第一个maven命令行是:
mvn clean install -e wildfly:deploy-only
避免 "package" 阶段。更多信息 aboy
感谢您的回答!