jacoco_build.xml 6.95 KB
<?xml version="1.0" ?>
<project name="Lengyu" xmlns:jacoco="antlib:org.jacoco.ant" default="jacoco">
    <!--Jacoco的安装路径-->
  <property name="jacocoantPath" value="/Data/local/jacoco/lib/jacocoant.jar"/>

    <!--工程名称,需要跟自己工程在代码发布机上的目录一致-->
    <property name="project_name" value="ufo-gateway" />

    <!--远程tomcat服务的ip地址-->
    <property name="server_ip" value="10.66.101.7"/>
    <!--前面配置的远程tomcat服务打开的端口,要跟env.sh中CATALINA_OPTS配置的Agent端口一样-->
    <property name="server_port" value="8891"/>

  <!--最终生成.exec文件的路径,Jacoco就是根据这个文件生成最终的报告的-->
  <property name="jacocoexecFile" value="/Data/local/jacoco/jacoco-dumps/${project_name}"/>
    <!--生成覆盖率报告的路径-->
  <property name="reportfolderPath" value="/Data/local/jacoco/jacoco-report/${project_name}"/>

   <!--代码发布机上工程的默认路径-->
    <property name="code_base" value="/home/master/auto_deploy/apps/${project_name}/qcloud_gray/gray" />


  <!--让ant知道去哪儿找Jacoco-->
  <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
      <classpath path="${jacocoantPath}" />
  </taskdef>

  <!--dump任务:
      根据前面配置的ip地址,和端口号,
      访问目标tomcat服务,并生成.exec文件。-->
  <target name="dump">
      <jacoco:dump address="${server_ip}" reset="false" destfile="${jacocoexecFile}" port="${server_port}" append="true"/>
  </target>
  
  <!--jacoco任务:
      根据前面配置的源代码路径和.class文件路径,
      根据dump后,生成的.exec文件,生成最终的html覆盖率报告。-->
  <target name="report">
      <delete dir="${reportfolderPath}" />
      <mkdir dir="${reportfolderPath}" />
      
      <jacoco:report>
          <executiondata>
              <file file="${jacocoexecFile}" />
          </executiondata>
              
          <structure name="JaCoCo Report">
              <group name="backend">
                  <classfiles>
                      <fileset dir="${code_base}/backend/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/backend/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="cms">
                  <classfiles>
                      <fileset dir="${code_base}/cms/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/cms/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="common">
                  <classfiles>
                      <fileset dir="${code_base}/common/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/common/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="guide">
                  <classfiles>
                      <fileset dir="${code_base}/guide/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/guide/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="message">
                  <classfiles>
                      <fileset dir="${code_base}/message/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/message/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="offlineshop">
                  <classfiles>
                      <fileset dir="${code_base}/offlineshop/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/offlineshop/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="order">
                  <classfiles>
                      <fileset dir="${code_base}/order/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/order/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="payment">
                  <classfiles>
                      <fileset dir="${code_base}/payment/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/payment/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="product">
                  <classfiles>
                      <fileset dir="${code_base}/product/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/product/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="promotion">
                  <classfiles>
                      <fileset dir="${code_base}/promotion/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/promotion/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="seller">
                  <classfiles>
                      <fileset dir="${code_base}/seller/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/seller/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="service">
                  <classfiles>
                      <fileset dir="${code_base}/service/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/service/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="sns">
                  <classfiles>
                      <fileset dir="${code_base}/sns/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/sns/src/main/java" />
                  </sourcefiles>
              </group>
              <group name="users">
                  <classfiles>
                      <fileset dir="${code_base}/users/target/classes" />
                  </classfiles>
                  <sourcefiles encoding="gbk">
                      <fileset dir="${code_base}/users/src/main/java" />
                  </sourcefiles>
              </group>
          </structure>

          <html destdir="${reportfolderPath}" encoding="utf-8" />         
      </jacoco:report>
  </target>
</project>