maven之pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  
  <!-- 
                  Default (or Build) 生命周期
          validate    检查工程配置是否正确,完成构建过程的全部必要信息是否可以获取到。
        initialize    初始化构建状态,例如设置属性。
        generate-sources    生成编译阶段须要包含的任何源码文件。
        process-sources    处理源代码,例如,过滤任何值(filter any value)。
        generate-resources    生成工程包中须要包含的资源文件。
        process-resources    拷贝和处理资源文件到目的目录中,为打包阶段作准备。
        compile    编译工程源码。
        process-classes    处理编译生成的文件,例如 Java Class 字节码的增强和优化。
        generate-test-sources    生成编译阶段须要包含的任何测试源代码。
        process-test-sources    处理测试源代码,例如,过滤任何值(filter any values)。
        test-compile    编译测试源代码到测试目的目录。
        process-test-classes    处理测试代码文件编译后生成的文件。
        test    使用适当的单元测试框架(例如JUnit)运行测试。
        prepare-package    在真正打包以前,为准备打包执行任何须要的操做。
        package    获取编译后的代码,并按照可发布的格式进行打包,例如 JAR、WAR 或者 EAR 文件。
        pre-integration-test    在集成测试执行以前,执行所需的操做。例如,设置所需的环境变量。
        integration-test    处理和部署必须的工程包到集成测试可以运行的环境中。
        post-integration-test    在集成测试被执行后执行必要的操做。例如,清理环境。
        verify    运行检查操做来验证工程包是有效的,并知足质量要求。
        install    安装工程包到本地仓库中,该仓库能够做为本地其余工程的依赖。
        deploy    拷贝最终的工程包到远程仓库中,以共享给其余开发人员和工程。
  
          说明:mvn compile,只有该阶段以前以及包括该阶段在内的全部阶段会被执行。
   -->
  
  <modelVersion>4.0.0</modelVersion>
  <!-- 工程组的标识 -->
  <groupId>com.maven.com</groupId>
  <!-- 工程的标识 -->
  <artifactId>maven</artifactId>
  <!-- 打包成的类型:war jar -->
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>maven Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <properties>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <!-- 远程仓库 -->
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <!-- 外部依赖 (当不能使用远程仓库时,能够考虑外部依赖)-->
    <!--  
    <dependency>
        <groupId>ojdbc</groupId>
        <artifactId>ojdbc</artifactId>
        <scope>system</scope>
        <version>1.0</version>
        <systemPath>${basedir}\src\main\resources\ojdbc.jar</systemPath>
    </dependency>
    -->
  </dependencies>
  <build>
    <finalName>maven</finalName>
    <!-- 插件 -->
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <id>id.clean</id>
                    <phase>clean</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <echo>clean phase</echo>
                        </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <!-- mvn:site Maven Site 插件通常用来建立新的报告文档、部署站点等 -->
        <!-- 
            site生命周期:
                pre-site
                site
                post-site
                site-deploy
         -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.1</version>
            <executions>
              <execution>
                 <id>id.pre-site</id>
                 <phase>pre-site</phase>
                 <goals>
                    <goal>run</goal>
                 </goals>
                 <configuration>
                    <tasks>
                       <echo>pre-site phase</echo>
                    </tasks>
                 </configuration>
              </execution>
              <execution>
                 <id>id.site</id>
                 <phase>site</phase>
                 <goals>
                 <goal>run</goal>
                 </goals>
                 <configuration>
                    <tasks>
                       <echo>site phase</echo>
                    </tasks>
                 </configuration>
              </execution>
              <execution>
                 <id>id.post-site</id>
                 <phase>post-site</phase>
                 <goals>
                    <goal>run</goal>
                 </goals>
                 <configuration>
                    <tasks>
                       <echo>post-site phase</echo>
                    </tasks>
                 </configuration>
              </execution>
              <execution>
                 <id>id.site-deploy</id>
                 <phase>site-deploy</phase>
                 <goals>
                    <goal>run</goal>
                 </goals>
                 <configuration>
                    <tasks>
                       <echo>site-deploy phase</echo>
                    </tasks>
                 </configuration>
              </execution>
           </executions>
        </plugin>
        <!-- 构建自动化:有两个项目依赖本项目,分别为 app-web-ui与app-desktop-ui,一旦本项目建立成功,则会加载app-web-ui与app-desktop-ui-->
        <!-- 具体实例:http://wiki.jikexueyuan.com/project/maven/build-automation.html -->
        <plugin>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>1.6</version>
            <configuration>
                <debug>true</debug>
                <pomIncludes>
                    <pomInclude>app-web-ui/pom.xml</pomInclude>
                    <pomInclude>app-desktop-ui/pom.xml</pomInclude>
                </pomIncludes>
            </configuration>
            <executions>
                <execution>
                    <id>build</id>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        
        <!-- maven自动化部署到tomcat: mvn clean package tomcat7:deploy  -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>  
            <artifactId>tomcat6-maven-plugin</artifactId> 
            <version>2.1</version>  
        </plugin>
        <plugin>
             <groupId>org.apache.tomcat.maven</groupId>  
             <artifactId>tomcat7-maven-plugin</artifactId>  
             <version>2.1</version> 
             <configuration>  
                 <server>local_server</server>
                 <url>http://localhost:8081/manager/text</url>
                 <path>/${project.build.finalName}</path>    
             </configuration>
        </plugin>
        
    </plugins>
  </build>
</project>
 html

相关文章
相关标签/搜索