2012-01-13 2 views
1

구글 앱 엔진, 구글 웹 툴킷 (플랫폼, gwtp) 및 이클립스로 메이븐을 시도한 것은 이번이 처음입니다. 우리는이 코드를 여기저기서 발견했습니다. 이 POM 파일을 개선 할 수 있을지 궁금해합니다. 특히 빌드 섹션에서 개선 할 수있는 부분이 무엇인지 궁금합니다.어떻게하면이 Paven.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 프로젝트가 하나뿐이라면 무엇이 공통이고 구체적인 내용인지 확신하기는 어렵지만 모두 똑같이 수행 할 가치가 있다고 생각합니다.

plugins 대신 pluginManagement 섹션에 구성을 추가로 개선하는 것이 좋습니다.

pluginManagement "나는이 플러그인을 사용해야하는 경우, 여기에 내가 원하는거야 구성이다 (나는 그것을 무시하도록 선택하지 않는 한).하지만을 사용합니다 I 을 말하는 게 아니에요"라고 말한다. plugins 섹션에는 "이 프로젝트를 빌드 할 때이 플러그인을 실행하고 싶을뿐 아니라 상속 된 내용이 아닌이 구성을 사용하십시오."라고 표시되어 있습니다.