百度空间 | 百度首页 
               
 
查看文章
 
Maven+GWT的POM配置
2008-11-12 00:22

  昨天折腾了好久才弄好GWT+Maven+NetBeans的整合配置,今天就看到有人写了篇Maven+GWT的POM配置指南,当真是很不爽,于是偷过来贴在这泄愤了!

  原文:Maven2 + GWT 1.5.3 + all platforms + tests

软件版本:
  - GWT 1.5.3
  - Maven 2.0.9

POM.XML文件内容如下:

  1. <!-- http://docs.codehaus.org/display/MAVENUSER/Profiles -->
  2. <profiles>
  3. <profile>
  4. <id>mac</id>
  5. <activation>
  6. <os>
  7. <family>mac</family>
  8. </os>
  9. </activation>
  10. <properties>
  11. <os>mac</os>
  12. </properties>
  13. </profile>
  14. <profile>
  15. <id>linux</id>
  16. <activation>
  17. <os>
  18. <name>linux</name>
  19. </os>
  20. </activation>
  21. <properties>
  22. <os>linux</os>
  23. </properties>
  24. </profile>
  25. <profile>
  26. <id>windows</id>
  27. <activation>
  28. <os>
  29. <family>windows</family>
  30. </os>
  31. </activation>
  32. <properties>
  33. <os>windows</os>
  34. </properties>
  35. <dependencies>
  36. <dependency>
  37. <groupId>com.google.gwt</groupId>
  38. <artifactId>dev-${os}</artifactId>
  39. <version>${gwtVersion}</version>
  40. <scope>system</scope>
  41. <systemPath>
  42. ${basedir}/gwt/gwt-${os}-${gwtVersion}/gwt-dev-${os}.jar
  43. </systemPath>
  44. </dependency>
  45. </dependencies>
  46. </profile>
  47. </profiles>

----------------------懒得翻译,下面直接贴原文内容----------------------

Note the profiles achieves two things:
Set the ${os} property (this cannot be achieved otherwise)
Add a dependency to the gwt-dev jar - which must reside in the same directoy as some other OS-specific files.
We still need to make sure that the OS-specific part is at the right place (here: ${basedir}/gwt ) at the right time (here: before using the dependencies for compile or test).

Next we need to declare the GWT specific dependencies in the pom. We simply uploaded those to our public maven repository as well (http://semweb4j.org/repo)

  1. <!-- gwt dependencies -->
  2. <dependency>
  3. <groupId>com.google.gwt</groupId>
  4. <artifactId>gwt-user</artifactId>
  5. <version>${gwtVersion}</version>
  6. <scope>provided</scope>
  7. </dependency>
  8. <dependency>
  9. <groupId>com.google.gwt</groupId>
  10. <artifactId>gwt-servlet</artifactId>
  11. <version>${gwtVersion}</version>
  12. </dependency>

Now comes the clever part:

  1. <dependency>
  2. <groupId>com.google.gwt</groupId>
  3. <artifactId>dist-${os}</artifactId>
  4. <version>${gwtVersion}</version>
  5. </dependency>

This instructs maven to fetch our special GWT-dist jar. We also need to unpack it at the right time, which is done here, in :

  1. <plugin>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-dependency-plugin</artifactId>
  4. <executions>
  5. <execution>
  6. <id>unpack-gwt</id>
  7. <phase>generate-sources</phase>
  8. <goals>
  9. <goal>unpack</goal>
  10. </goals>
  11. <configuration>
  12. <artifactItems>
  13. <artifactItem>
  14. <groupId>com.google.gwt</groupId>
  15. <artifactId>dist-${os}</artifactId>
  16. <version>1.5.3</version>
  17. <type>jar</type>
  18. <overWrite>true</overWrite>
  19. <outputDirectory>
  20. ${basedir}/gwt
  21. </outputDirectory>
  22. </artifactItem>
  23. </artifactItems>
  24. <!-- other configurations here -->
  25. </configuration>
  26. </execution>
  27. </executions>
  28. </plugin>

类别:Java | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu