2012-01-13 3 views
1

Это первый раз, когда мы пытаемся использовать maven с движком Google, веб-инструментарием google (платформа, gwtp) и eclipse. Мы поставили это с кодом, который мы нашли здесь и там. Интересно, если этот POM файл может быть улучшена, и как, так как мы уверены, что он может быть улучшен, в частности, в разделе сборки:Как мы можем сделать этот maven POM.xml более профессиональным?

<!-- 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> 

Спасибо!

ответ

3

Пользовательские свойства отличные, но не используют их только потому, что они существуют. Используйте их, чтобы устранить избыточность и/или отложить управление родительскими POM. Кроме этого, я не вижу ничего неправильного в отношении сферы вашего вопроса.

+0

@Tom: True. Просто избавитесь от всех свойств, которые используются один раз. –

1

Большая часть вашей конфигурации будет распространена для любого проекта gae-gwt-eclipse-maven. Таким образом, вы можете создать проект для стандартизации этой конфигурации (скажем gae-gwt-eclipse-base, с <packaging>pom</packaging>), содержащий все это, тогда ваш реальный проект наследует от этого POM и лишает себя всех перечисленных вами шаблонов. Действительно, он может быть полностью пустым, кроме идентификаторов и раздела <parent>, что будет означать объявление «Это стандартный проект GAE-GWT-Eclipse».

Если у вас есть только один проект GAE-GWT-Eclipse, трудно быть уверенным в том, что общего и что конкретно, но я думаю, что это может стоить того же.

Еще одним преимуществом было бы поставить конфигурацию в раздел pluginManagement вместо plugins.

pluginManagement говорит: «Если я должен использовать эти плагины, вот конфигурация я хочу (если я не переопределить его). Но я не говорю, что я будет использовать их.» В то время как в разделе plugins говорится: «Я хочу, чтобы вы запускали эти плагины при создании этого проекта», а возможно и «и используйте эту конфигурацию, а не все, что унаследовано».

Смежные вопросы