build.xml 5.9 KB

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