build.xml 6.2 KB

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