빌드는 maven으로 하고, sonar 구동 및 전체 수행은 ant 로 수행시키는 build.xml 예제.

사내 build에 적용해야 하는데, 아직 미 완성.
좀 더 프로세스를 구체화 시킨 후 적용할 예정이다.

<?xml version="1.0" encoding="UTF-8"?>
<project name="Sonar Ant Project" default="build" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
 <property environment="env"/>
 <path id="maven-ant-tasks.classpath" path="${basedir}/lib/maven-ant-tasks-2.1.1.jar"/>
 <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
             uri="antlib:org.apache.maven.artifact.ant"
             classpathref="maven-ant-tasks.classpath" />
 <taskdef resource="net/sf/antcontrib/antlib.xml">
   <classpath>
     <pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar" />
   </classpath>
 </taskdef>
 <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
    <classpath path="lib/sonar-ant-task-1.0.jar" />
 </taskdef>
 <target name="build" depends="mvn,sonar"/>
 <target name="mvn">
   <property name="maven.home" value="${env.M2_HOME}"/>
   <echo message="M2_HOME = ${maven.home}"/>
   <artifact:mvn pom="pom.xml" mavenHome="${maven.home}" fork="true" failonerror="true">
     <arg value="clean"/>
     <arg value="install"/>
     <arg value="-Dmaven.test.skip=true"/>
    </artifact:mvn>
 </target>
 <target name="sonar">
   <tstamp>
     <format property="build.time" pattern="yyyy-MM-dd.hh:mm" locale="en"/>
   </tstamp>
  <!--
  <property file="build.number" />
  <echo message="build.number = ${build.number}"/>
  <buildnumber file="build.number" />
  -->
  <!-- The workDir directory is used by Sonar to store temporary files -->
  <sonar:sonar workDir="." key="org.example:example" version="${build.time}" xmlns:sonar="antlib:org.sonar.ant">
    <sources>
      <path location="${basedir}/common/src/main/java"/>
      <path location="${basedir}/model/src/main/java"/>
      <path location="${basedir}/dao-api/src/main/java"/>
      <path location="${basedir}/dao-hibernate/src/main/java"/>
      <path location="${basedir}/agent/src/main/java"/>
      <path location="${basedir}/manager/src/main/java"/>
    </sources>
    <tests>
      <path location="${basedir}/common/src/test/java"/>
      <path location="${basedir}/model/src/test/java"/>
      <path location="${basedir}/dao-api/src/test/java"/>
      <path location="${basedir}/dao-hibernate/src/test/java"/>
      <path location="${basedir}/agent/src/test/java"/>
      <path location="${basedir}/manager/src/test/java"/>
    </tests>
   <!--
    1. binaries: binaries directories, which contain for example the compiled Java bytecode (optional)
    2. libraries: path to libraries (optional). These libraries are for example used by the Java Findbugs plugin
    <binaries>
      <path location="..." />
    </binaries>
    <libraries>
      <path location="..." />
    </libraries>
   -->
   <!-- list of properties (optional) -->
   <property key="sonar.projectName" value="Sonar Ant Project" />
   <property key="sonar.dynamicAnalysis" value="true" />
   <property key="sonar.jdbc.url" value="jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8" />
   <property key="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
   <property key="sonar.jdbc.username" value="sonar" />
   <property key="sonar.jdbc.password" value="sonar" />
   <property key="sonar.host.url" value="http://192.168.20.34:9000" />
   <property key="sonar.java.source" value="1.6" />
   <property key="sonar.java.target" value="1.6" />
  </sonar:sonar>
 </target>
</project>
sonar를 ant로 구동시키면, modules(sub-projects)가 지원되지 않는 점 때문인지, tree map이 package이름으로 번잡하게 나오고, tangle index 정보가 나오지 않는다. 안타깝다;

+ Recent posts