build.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <project name="tdd" default="tests" basedir="." xmlns:sonar="antlib:org.sonar.ant" xmlns:jacoco="antlib:org.jacoco.ant">
  2. <property name="project.java.version" value="1.8" />
  3. <property name="encoding" value="UTF-8" />
  4. <property name="sonar.login" value="TOKEN SONAR ICI" />
  5. <!-- LE RESTE DOIT ETRE BON -->
  6. <property name="build" value="build" />
  7. <property name="testreports" value="testreports" />
  8. <property name="src" value="src" />
  9. <!-- Define the SonarQube global properties (the most usual way is to pass these properties via the command line) -->
  10. <property name="sonar.host.url" value="https://forge.univ-artois.fr/sonar67" />
  11. <property name="sonar.projectKey" value="${etudiant}:2019:MyLisp" />
  12. <property name="sonar.projectName" value="${etudiant} Lisp 19" />
  13. <property name="sonar.projectVersion" value="1.0" />
  14. <property name="sonar.java.source" value="${project.java.version}" />
  15. <property name="sonar.java.binaries" value="build" />
  16. <property name="sonar.java.libraries" value="lib/*.jar" />
  17. <property name="sonar.sources" value="src" />
  18. <property name="sonar.exclusions" value="**/*Test*" />
  19. <property name="sonar.tests" value="TDD2019TESTS/src,TDD2019OWNTESTS/src" />
  20. <property name="sonar.junit.reportPaths" value="${testreports}" />
  21. <property name="sonar.jacoco.reportPaths" value="${testreports}/jacoco.exec" />
  22. <property name="sonar.pitest.reportsDirectory" value="${testreports}" />
  23. <property name="sonar.web.javaAdditionalOpts" value="-Dhttps.proxyHost=cache-etu.univ-artois.fr -Dhttps.proxyPort=3128" />
  24. <target name="prepare" description="Cree les repertoires et initialise certaines valeurs">
  25. <!-- Create the time stamp -->
  26. <tstamp />
  27. <mkdir dir="${build}" />
  28. <mkdir dir="${testreports}" />
  29. </target>
  30. <path id="mypath">
  31. <pathelement location="${build}" />
  32. <fileset dir="lib">
  33. <include name="*.jar" />
  34. </fileset>
  35. </path>
  36. <target name="build" description="Compile les fichiers Java" depends="prepare">
  37. <javac includeantruntime="true" srcdir="${src}" destdir="${build}" source="${project.java.version}" debug="true" encoding="${encoding}">
  38. <classpath refid="mypath" />
  39. </javac>
  40. </target>
  41. <target name="clean" description="Efface tous les fichiers generes">
  42. <!-- Delete directory trees -->
  43. <delete dir="${build}" />
  44. <delete dir="${testreports}" />
  45. <delete dir="${target}" />
  46. </target>
  47. <target name="compilepublictests">
  48. <echo>Compilation des tests publics</echo>
  49. <javac includeantruntime="true" srcdir="TDD2019TESTS/src" destdir="${build}" source="${project.java.version}" debug="true" encoding="${encoding}">
  50. <classpath refid="mypath" />
  51. </javac>
  52. <copy todir="${build}">
  53. <fileset dir="TDD2019TESTS/src">
  54. <include name="**/*.story" />
  55. </fileset>
  56. </copy>
  57. </target>
  58. <target name="compileprivatetests" if="private.tests.found">
  59. <echo>Compilation des tests privés</echo>
  60. <javac includeantruntime="true" srcdir="TDD2019HIDDENTESTS/src" destdir="${build}" source="${project.java.version}" debug="true" encoding="${encoding}">
  61. <classpath refid="mypath" />
  62. </javac>
  63. <copy todir="${build}">
  64. <fileset dir="TDD2019HIDDENTESTS/src">
  65. <include name="**/*.story" />
  66. </fileset>
  67. </copy>
  68. </target>
  69. <target name="compileowntests">
  70. <echo>Compilation des tests personnels</echo>
  71. <javac includeantruntime="true" srcdir="TDD2019OWNTESTS/src" destdir="${build}" source="${project.java.version}" debug="true" encoding="${encoding}">
  72. <classpath refid="mypath" />
  73. </javac>
  74. <copy todir="${build}">
  75. <fileset dir="TDD2019OWNTESTS/src">
  76. <include name="**/*.story" />
  77. </fileset>
  78. </copy>
  79. </target>
  80. <target name="tests" description="test de l'application web à l'aide de JUnit" depends="build">
  81. <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
  82. <classpath path="lib/jacocoant.jar" />
  83. </taskdef>
  84. <antcall target="compilepublictests" />
  85. <available property="private.tests.found" file="TDD2019HIDDENTESTS/src" type="dir" />
  86. <antcall target="compileprivatetests" />
  87. <antcall target="compileowntests" />
  88. <jacoco:coverage destfile="${sonar.jacoco.reportPath}">
  89. <junit fork="yes" forkmode="once" printsummary="false" haltonfailure="no" failureproperty="tests.failure">
  90. <classpath refid="mypath" />
  91. <formatter type="plain" usefile="false" />
  92. <formatter type="xml" />
  93. <batchtest fork="yes" todir="${testreports}">
  94. <fileset dir="${build}">
  95. <include name="**/TDD*.class" />
  96. <include name="**/*Test*.class" />
  97. <include name="**/PeterNorvig*.class" />
  98. <exclude name="**/AllTests.class" />
  99. <exclude name="**/Abstract*.class" />
  100. </fileset>
  101. </batchtest>
  102. </junit>
  103. </jacoco:coverage>
  104. </target>
  105. <target name="m1" description="Verification des projets de TDD2019" depends="clean,build,tests,mutationCoverage" />
  106. <!-- Define the SonarQube target -->
  107. <target name="sonar" depends="m1" description="Analyse le code avec SonarQube">
  108. <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
  109. <classpath path="lib/sonarqube-ant-task-2.5.jar" />
  110. </taskdef>
  111. <!-- To avoid analyzing the tests -->
  112. <delete dir="${build}" />
  113. <mkdir dir="${build}" />
  114. <antcall target="build" />
  115. <!-- Execute the SonarQube analysis -->
  116. <sonar:sonar />
  117. <fail message="Il reste des tests qui ne passent pas !" if="tests.failure" />
  118. </target>
  119. <target name="mutationCoverage">
  120. <taskdef name="pitest" classname="org.pitest.ant.PitestTask" classpathref="mypath" />
  121. <pitest
  122. pitClasspath="mypath"
  123. classPath="mypath"
  124. targetClasses="migl.*"
  125. excludedMethods="*hashCode()"
  126. excludedClasses="*Test*,*Eval*"
  127. targetTests="migl.*"
  128. reportDir="${testreports}"
  129. outputFormats="XML,HTML"
  130. sourceDir="${src}"/>
  131. </target>
  132. </project>