<< What does the exception "java.net.SocketException: Connection reset by peer" mean? How can this be avoided? | 首页 | 用 Cobertura 测量测试覆盖率 >>

Maven2 一个完整的pom.xml

Maven2是一个很好的build工具,它简化了项目管理,用它的插件可生成各种报表,自动化测试等等。但是把已有的项目转移到Maven2上其实是一件痛苦的事情,但关键在于要理解 pom.xml文件。我的经验是,一旦你的应用包依赖搞定了的话,就用mvn -o site来离线进行maven2工作

安装第三方包:
mvn install:install-file -Dfile=E:/workdir/dg_new/主站/源代码/m2m/lib/mail-1.3.jar -DartifactId=javamail -Dversion=1.3.1 -Dpackaging=jar -DgroupId=javamail

遵循Maven2的规范源代码目录。

创建新项目:

mvn archetype:create -DgroupId=cas.security -DartifactId=securityApp -DarchetypeArtifactId=maven-archetype-webapp

cd securityApp

创建war文件:

mvn package

创建Eclipse项目文件:

mvn eclipse:eclipse

部署 webapps internal (so we can point the Context.xml file in tomcat to the source dir):

mvn war:inplace

mvn test

mvn compile

(The above should copy the jar files we need.)

Add M2_REPO to workspace:
mvn -Declipse.workspace=D:\workspaces\clientQ

eclipse:add-maven-repo

Maven文档:http://maven.apache.org/guides/getting-started/index.html

下面是一个完整的pom.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
 <modelVersion>4.0.0</modelVersion>
 <groupId>tudu</groupId>
 <artifactId>tudu</artifactId>
 <packaging>war</packaging>
 <name>Tudu Lists</name>
 <version>1.1-rc-1</version>
 <description>
  A Web application for managing todo lists.
 </description>
 <url>http://sourceforge.net/projects/tudu/</url>
 <issueManagement>
  <system>SourceForge</system>
  <url>http://sourceforge.net/tracker/?group_id=131842</url>
 </issueManagement>
 <inceptionYear>2005</inceptionYear>
 <repositories>
  <repository>
   <id>maven2</id>
   <name>Default Maven2 repository</name>
   <url>http://repo1.maven.org/maven2</url>
  </repository>
  <repository>
   <id>julien.dubois.private.repo</id>
   <name>
    Julien Dubois private Maven repository - personnal use
    only
   </name>
   <url>http://julien.dubois.free.fr/maven2</url>
  </repository>
 </repositories>
 <developers>
  <developer>
   <name>Julien Dubois</name>
   <id>roullian</id>
   <email></email>
   <url>http://www.julien-dubois.com</url>
   <organization></organization>
  </developer>
  <developer>
   <name>Jerome Morille</name>
   <id>jmorille</id>
   <email></email>
   <organization></organization>
  </developer>
  <developer>
   <name>Jean-Philippe Retaille</name>
   <id>retaille</id>
   <email></email>
   <organization></organization>
  </developer>
  <developer>
   <name>Ralph Schaer</name>
   <id>rasch</id>
   <email></email>
   <organization></organization>
  </developer>
  <developer>
   <name>Thierry Templier</name>
   <id>templth</id>
   <email></email>
   <organization></organization>
  </developer>
 </developers>
 <licenses>
  <license>
   <name>GNU General Public License</name>
   <url>http://www.gnu.org/copyleft/gpl.html</url>
  </license>
 </licenses>
 <dependencies>
  <dependency>
   <groupId>aspectj</groupId>
   <artifactId>aspectjrt</artifactId>
   <version>1.5.0</version>
   <scope>runtime</scope>
  </dependency>
  <dependency>
   <groupId>aspectj</groupId>
   <artifactId>aspectjweaver</artifactId>
   <version>1.5.0</version>
   <scope>runtime</scope>
  </dependency>
  <dependency>
   <groupId>axis</groupId>
   <artifactId>axis-ant</artifactId>
   <version>1.3</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>axis</groupId>
   <artifactId>axis-ant</artifactId>
   <version>1.3</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>axis</groupId>
   <artifactId>axis</artifactId>
   <version>1.3</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>axis</groupId>
   <artifactId>axis-saaj</artifactId>
   <version>1.3</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>axis</groupId>
   <artifactId>axis-wsdl4j</artifactId>
   <version>1.3</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>com.jamonapi</groupId>
   <artifactId>jamon</artifactId>
   <version>1.0</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>commons-lang</groupId>
   <artifactId>commons-lang</artifactId>
   <version>2.1</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>1.0.4</version>
   <scope>compile</scope>
   <exclusions>
    <exclusion>
     <groupId>logkit</groupId>
     <artifactId>logkit</artifactId>
    </exclusion>
    <exclusion>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
    </exclusion>
    <exclusion>
     <groupId>avalon-framework</groupId>
     <artifactId>avalon-framework</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
  <dependency>
   <groupId>dbunit</groupId>
   <artifactId>dbunit</artifactId>
   <version>2.1</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>dom4j</groupId>
   <artifactId>dom4j</artifactId>
   <version>1.6</version>
   <exclusions>
    <exclusion>
     <groupId>jaxme</groupId>
     <artifactId>jaxme-api</artifactId>
    </exclusion>
    <exclusion>
     <groupId>jaxen</groupId>
     <artifactId>jaxen</artifactId>
    </exclusion>
    <exclusion>
     <groupId>msv</groupId>
     <artifactId>xsdlib</artifactId>
    </exclusion>
    <exclusion>
     <groupId>msv</groupId>
     <artifactId>relaxngDatatype</artifactId>
    </exclusion>
    <exclusion>
     <groupId>pull-parser</groupId>
     <artifactId>pull-parser</artifactId>
    </exclusion>
    <exclusion>
     <groupId>xpp3</groupId>
     <artifactId>xpp3</artifactId>
    </exclusion>
    <exclusion>
     <groupId>stax</groupId>
     <artifactId>stax-api</artifactId>
    </exclusion>
    <exclusion>
     <groupId>xml-apis</groupId>
     <artifactId>xml-apis</artifactId>
    </exclusion>
    <exclusion>
     <groupId>junitperf</groupId>
     <artifactId>junitperf</artifactId>
    </exclusion>
    <exclusion>
     <groupId>stax</groupId>
     <artifactId>stax-ri</artifactId>
    </exclusion>
    <exclusion>
     <groupId>xalan</groupId>
     <artifactId>xalan</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
  <dependency>
   <groupId>ehcache</groupId>
   <artifactId>ehcache</artifactId>
   <version>1.1</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>hsqldb</groupId>
   <artifactId>hsqldb</artifactId>
   <version>1.8.0.1</version>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>javax.activation</groupId>
   <artifactId>activation</artifactId>
   <version>1.0.2</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>javax.mail</groupId>
   <artifactId>mail</artifactId>
   <version>1.3.2</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.1.2</version>
   <scope>compile</scope>
   <exclusions>
    <exclusion>
     <groupId>javax.servlet</groupId>
     <artifactId>jsp-api</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>2.4</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>jdom</groupId>
   <artifactId>jdom</artifactId>
   <version>1.0</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
   <version>1.2.13</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>rome</groupId>
   <artifactId>rome</artifactId>
   <version>0.5</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.acegisecurity</groupId>
   <artifactId>acegi-security</artifactId>
   <version>1.0.0-RC1</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.easymock</groupId>
   <artifactId>easymock</artifactId>
   <version>2.0</version>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate</artifactId>
   <version>3.1.2</version>
   <scope>compile</scope>
   <exclusions>
    <exclusion>
     <groupId>javax.transaction</groupId>
     <artifactId>jta</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aop</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aspects</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-beans</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-core</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-dao</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-hibernate3</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
   <exclusions>
    <exclusion>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-annotations</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jdbc</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-mock</artifactId>
   <version>2.0-m2</version>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-remoting</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-support</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>2.0-m2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>struts</groupId>
   <artifactId>struts</artifactId>
   <version>1.2.8</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>struts-menu</groupId>
   <artifactId>struts-menu</artifactId>
   <version>2.3</version>
   <scope>runtime</scope>
   <exclusions>
    <exclusion>
     <groupId>hsqldb</groupId>
     <artifactId>hsqldb</artifactId>
    </exclusion>
    <exclusion>
     <groupId>velocity</groupId>
     <artifactId>velocity</artifactId>
    </exclusion>
    <exclusion>
     <groupId>velocity-tools</groupId>
     <artifactId>velocity-tools</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
  <dependency>
   <groupId>strutstestcase</groupId>
   <artifactId>strutstestcase</artifactId>
   <version>2.1.2-1.1-2.3</version>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>taglibs</groupId>
   <artifactId>standard</artifactId>
   <version>1.1.2</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>tomcat</groupId>
   <artifactId>jsp-api</artifactId>
   <version>5.0.18</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>uk.ltd.getahead</groupId>
   <artifactId>dwr</artifactId>
   <version>1.1-SNAPSHOT</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>xfire</groupId>
   <artifactId>xfire-all</artifactId>
   <version>1.0-M6</version>
   <scope>deploy</scope>
   <exclusions>
    <exclusion>
     <groupId>javamail</groupId>
     <artifactId>javamail</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
 </dependencies>
 <reporting>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>
     maven-project-info-reports-plugin
    </artifactId>
    <reportSets>
     <reportSet>
      <reports>
       <report>dependencies</report>
       <report>project-team</report>
       <report>issue-tracking</report>
       <report>license</report>
       <report>scm</report>
      </reports>
     </reportSet>
    </reportSets>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
   </plugin>
   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>surefire-report-maven-plugin</artifactId>
   </plugin>
   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jxr-maven-plugin</artifactId>
   </plugin>
  </plugins>
 </reporting>
 <scm>
  <connection>
   scm:cvs:pserver:[email protected]:/cvsroot/tudu:tudu
  </connection>
  <developerConnection>
   scm:cvs:extssh:${maven.username}@cvs.sourceforge.net:/cvsroot/tudu:tudu
  </developerConnection>
  <url>http://cvs.sourceforge.net/viewcvs.py/tudu/tudu/</url>
 </scm>
 <build>
  <sourceDirectory>src/java</sourceDirectory>
  <testSourceDirectory>test/java</testSourceDirectory>
  <resources>
   <resource>
    <directory>src/resources</directory>
   </resource>
  </resources>
  <testResources>
   <testResource>
    <directory>test/resources</directory>
   </testResource>
  </testResources>
  <plugins>
   <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
     <descriptor>
      src/main/assembly/distribution.xml
     </descriptor>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <inherited>true</inherited>
    <configuration>
     <source>1.5</source>
     <target>1.5</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
     <systemProperties>
      <property>
       <name>tudu.webapp.dir</name>
       <value>${basedir}/src/webapp/</value>
      </property>
     </systemProperties>
     <excludes>
      <exclude>
       tudu/web/TuduBaseMockStrutsTestCase.java
      </exclude>
     </excludes>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
     <warSourceDirectory>src/webapp</warSourceDirectory>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <configuration>
     <locales>en</locales>
    </configuration>
   </plugin>
  </plugins>
 </build>
 <distributionManagement>
  <site>
   <id>tudu-website</id>
   <url>scp://shell.sf.net/home/groups/t/tu/tudu/htdocs/</url>
  </site>
 </distributionManagement>
</project>

标签 :



发表评论 发送引用通报