这是我们第一次尝试使用谷歌应用引擎,谷歌网络工具包(平台,gwtp)和eclipse。我们在这里和那里找到了代码。我们想知道这个POM文件是否可以改进以及如何改进,因为我们非常确定它可以改进,特别是构建部分:
<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.feeling</groupId>
<artifactId>order2012</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>com.feeling.order2012</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwt.version>2.4.0</gwt.version>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<gwtp.version>0.6</gwtp.version>
<gae.version>1.6.0</gae.version>
<gae.home>${user.home}/.m2/repository/com/google/appengine/appengine-java-sdk/${gae.version}/appengine-java-sdk-${gae.version}</gae.home>
<persistence-api.version>1.0</persistence-api.version>
<jsr107cache.version>1.1</jsr107cache.version>
<gin.version>1.5.0</gin.version>
<guice.version>3.0-rc3</guice.version>
<aopalliance.version>1.0</aopalliance.version>
<gwt-maven-plugin.version>2.4.0</gwt-maven-plugin.version>
<maven-gae-plugin.version>0.9.2</maven-gae-plugin.version>
<maven-clean-plugin.version>2.3</maven-clean-plugin.version>
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
<maven-deploy-plugin.version>2.5</maven-deploy-plugin.version>
<maven-eclipse-plugin.version>2.8</maven-eclipse-plugin.version>
<maven-javadoc-plugin.version>2.7</maven-javadoc-plugin.version>
<maven-resources-plugin.version>2.5</maven-resources-plugin.version>
<slf4f.version>1.6.1</slf4f.version>
<maven-source-plugin.version>2.1.2</maven-source-plugin.version>
<maven-checkstyle-plugin.version>2.6</maven-checkstyle-plugin.version>
<localJarDirectory>/Users/healuser/Documents/myGAE10/lib</localJarDirectory>
</properties>
<dependencies>….</dependencies>
<repositories>….</repositories>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>target/www/WEB-INF/classes</outputDirectory>
<plugins>
<!-- Add source folders to test classpath in order to run gwt-tests as
normal junit-tests <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
<additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
</additionalClasspathElements>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
! - - Folder for generated testing stuff - -
<systemProperties>
<property>
<name>gwt.args</name>
<value>-out target/www</value>
</property>
</systemProperties>
</configuration>
</plugin> -->
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
<configuration>
<encoding>${project.encoding}</encoding>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/www</outputDirectory>
<resources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Eclipse configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>${maven-eclipse-plugin.version}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<wtpversion>2.0</wtpversion>
<additionalBuildcommands>
<buildCommand>
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
</buildCommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
<projectnature>com.google.appengine.eclipse.core.gaeNature</projectnature>
<projectnature>net.sf.eclipsecs.core.CheckstyleNature</projectnature>
</additionalProjectnatures>
<additionalConfig>
<file>
<name>.checkstyle</name>
<location>/checkstyle/eclipse-checkstyle.xml</location>
</file>
</additionalConfig>
<sourceIncludes>
<sourceInclude>*.ui.xml</sourceInclude>
</sourceIncludes>
</configuration>
</plugin>
<!-- GWT configuration -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt-maven-plugin.version}</version>
<configuration>
<appEngineVersion>${gae.version}</appEngineVersion>
<appEngineHome>${gae.home}</appEngineHome>
<logLevel>INFO</logLevel>
<style>
$ {
gwt.style
}
</style>
<hostedWebapp>target/www</hostedWebapp>
<server>com.google.appengine.tools.development.gwt.AppEngineLauncher</server>
<copyWebapp>true</copyWebapp>
<runTarget>order2012.html</runTarget>
</configuration>
<executions>
<execution>
<id>gwtcompile</id>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- AppEngine configuration -->
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>${maven-gae-plugin.version}</version>
<configuration>
<sdkDir>${gae.home}</sdkDir>
</configuration>
<executions>
<execution>
<id>install-server-jar</id>
<phase>validate</phase>
<goals>
<goal>unpack</goal>
</goals>
</execution>
<execution>
<id>deploy</id>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven-clean-plugin.version}</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>remove-gwt-user-jar</id>
<phase>post-installation-test</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</directory>
<includes>
<include>gwt-user*.jar</include>
</includes>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/order2012</directory>
</fileset>
<fileset>
<directory>src/main/webapp/WEB-INF/classes</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<versionRange>[0.8.1,)</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
谢谢!
答案 0 :(得分:3)
自定义属性非常棒但不要仅因为它们存在而使用它们。使用它们来消除冗余和/或将管理推迟到父POM。除此之外,我认为你的问题范围没有任何错误。
答案 1 :(得分:1)
您的大部分配置都适用于任何gae-gwt-eclipse-maven项目。因此,您可以创建一个项目来标准化该配置(例如gae-gwt-eclipse-base
,其中包含<packaging>pom</packaging>
),然后您的真实项目将从该POM继承并剥离您列出的所有样板文件。实际上,除了标识符和<parent>
部分之外,它可能完全是空的,这相当于声明“这是一个标准的GAE-GWT-Eclipse项目。”
如果您只有一个GAE-GWT-Eclipse项目,很难确定哪些是常见的,哪些是具体的,但我认为值得做同样的事情。
另一项改进是将配置放入pluginManagement
部分而不是plugins
。
pluginManagement
说,“如果我应该使用这些插件,这是我想要的配置(除非我选择覆盖它)。但我不是说我将使用他们。”而plugins
部分说“我希望你在构建这个项目时执行这些插件”,而且也许,“并使用这个配置而不是你继承的任何东西。”