[DEV] ant is 9°% of the basis

This commit is contained in:
Edouard DUPIN 2020-09-06 23:05:15 +02:00
parent 487cba9ccb
commit 3966c55232
2 changed files with 141 additions and 61 deletions

6
.gitignore vendored
View File

@ -9,5 +9,9 @@ ScenariumConfig.txt
*.class *.class
*~ *~
*.bck *.bck
build.number
/extern/
/out/
/.settings/
/junit/
/target/ /target/

196
build.xml
View File

@ -1,21 +1,31 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="scenarium-logger" xmlns:jacoco="antlib:org.jacoco.ant"> <project basedir="." default="build" name="scenarium-logger" xmlns:jacoco="antlib:org.jacoco.ant">
<property environment="env"/> <property environment="env"/>
<property name="version" value="0.1.0" />
<property name="debuglevel" value="source,lines,vars"/> <property name="debuglevel" value="source,lines,vars"/>
<!-- configure dependency of JAVA --> <!-- configure dependency of JAVA -->
<property name="target" value="14"/> <property name="target" value="14"/>
<property name="source" value="14"/> <property name="source" value="14"/>
<property name="source.lib.dir" location="./src/" />
<property name="source.test.dir" location="./test/src/" />
<property name="result.dir" location="./out/ant/" /> <property name="result.dir" location="./out/ant/" />
<property name="result.jar.dir" location="${result.dir}/package" />
<property name="result.javadoc.dir" location="${result.dir}/javadoc" />
<property name="result.juint.dir" location="${result.dir}/junit" /> <property name="result.juint.dir" location="${result.dir}/junit" />
<property name="result.classes.dir" location="${result.dir}/classes" /> <property name="result.classes.lib.dir" location="${result.dir}/classes-lib" />
<property name="result.report.dir" location="${result.dir}/site/jacoco" /> <property name="result.classes.test.dir" location="${result.dir}/classes-test" />
<property name="result.exec.file" location="${result.dir}/jacoco.exec" /> <property name="result.coverage.report.dir" location="${result.dir}/coverage/site" />
<property name="result.coverage.work-file" location="${result.dir}/coverage/jacoco.exec" />
<!-- Import JaCoCo Ant tasks --> <!-- Import JaCoCo Ant tasks -->
<!-- https://www.eclemma.org/jacoco/-->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"> <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="/home/heero/jacoco/jacocoant.jar" /> <classpath path="${basedir}/extern/jacoco/jacocoant.jar" />
</taskdef> </taskdef>
<property name="libPath" value="${user.home}"/> <property name="libPath" value="${basedir}/extern/lib/"/> <!--value="${user.home}"-->
<!-- <!--
mkdir -p extern/lib mkdir -p extern/lib
cd extern/lib cd extern/lib
@ -37,109 +47,168 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
--> -->
<path id="junit.classpath"> <path id="junit.classpath">
<!-- keep all lib in this directiry--> <!-- keep all lib in this directiry-->
<fileset dir="${basedir}/extern/lib/"/> <fileset dir="${libPath}"/>
<!-- <!--
<pathelement location="${basedir}/extern/lib/junit-jupiter-api-5.6.2.jar"/> <pathelement location="${basedir}/junit-jupiter-api-5.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-jupiter-engine-5.6.2.jar"/> <pathelement location="${basedir}/junit-jupiter-engine-5.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-jupiter-migrationsupport-5.6.2.jar"/> <pathelement location="${basedir}/junit-jupiter-migrationsupport-5.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-jupiter-params-5.6.2.jar"/> <pathelement location="${basedir}/junit-jupiter-params-5.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-platform-commons-1.6.2.jar"/> <pathelement location="${basedir}/junit-platform-commons-1.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-platform-engine-1.6.2.jar"/> <pathelement location="${basedir}/junit-platform-engine-1.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-platform-launcher-1.6.2.jar"/> <pathelement location="${basedir}/junit-platform-launcher-1.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-jupiter-runner-5.6.2.jar"/> <pathelement location="${basedir}/junit-jupiter-runner-5.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-platform-suite-api-1.6.2.jar"/> <pathelement location="${basedir}/junit-platform-suite-api-1.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/junit-vintage-engine-5.6.2.jar"/> <pathelement location="${basedir}/junit-vintage-engine-5.6.2.jar"/>
<pathelement location="${basedir}/extern/lib/opentest4j-1.2.0.jar"/> <pathelement location="${basedir}/opentest4j-1.2.0.jar"/>
<pathelement location="${basedir}/extern/lib/apiguardian-api-1.1.0.jar"/> <pathelement location="${basedir}/apiguardian-api-1.1.0.jar"/>
<pathelement location="${basedir}/extern/lib/junit-4.13.jar"/> <pathelement location="${basedir}/junit-4.13.jar"/>
<pathelement location="${basedir}/extern/lib/hamcrest-core-1.3.jar"/> <pathelement location="${basedir}/hamcrest-core-1.3.jar"/>
--> -->
</path> </path>
<path id="scenarium-logger.classpath"> <path id="io.scenarium.logger.classpath">
<pathelement location="target/classes"/> <pathelement location="${result.classes.lib.dir}"/>
<pathelement location="target/test-classes"/> </path>
<path refid="junit.classpath"/> <path id="test.scenarium.logger.classpath">
</path> <path refid="io.scenarium.logger.classpath"/>
<path id="run.TestBasicLog.classpath"> <pathelement location="${result.classes.test.dir}"/>
<path refid="scenarium-logger.classpath"/>
<path refid="junit.classpath"/> <path refid="junit.classpath"/>
</path> </path>
<!-- =========================================================================== -->
<!-- initialize the build system -->
<!-- =========================================================================== -->
<target name="init"> <target name="init">
<mkdir dir="target/classes"/> <mkdir dir="${result.classes.lib.dir}"/>
<mkdir dir="target/test-classes"/> <mkdir dir="${result.classes.test.dir}"/>
<copy includeemptydirs="false" todir="target/classes"> <copy includeemptydirs="false" todir="${result.classes.lib.dir}">
<fileset dir="src"> <fileset dir="${source.lib.dir}">
<exclude name="**/*.launch"/> <exclude name="**/*.launch"/>
<exclude name="**/*.java"/> <exclude name="**/*.java"/>
</fileset> </fileset>
</copy> </copy>
<copy includeemptydirs="false" todir="target/test-classes"> <copy includeemptydirs="false" todir="${result.classes.test.dir}">
<fileset dir="test/src"> <fileset dir="${source.test.dir}">
<include name="**/*.java"/> <include name="**/*.java"/>
<exclude name="**/*.launch"/> <exclude name="**/*.launch"/>
<exclude name="**/*.java"/> <exclude name="**/*.java"/>
</fileset> </fileset>
</copy> </copy>
</target> </target>
<!-- =========================================================================== -->
<!-- clean all the build-tree -->
<!-- =========================================================================== -->
<target name="clean"> <target name="clean">
<delete dir="target/classes"/> <delete dir="${result.dir}/"/>
<delete dir="target/test-classes"/>
</target> </target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/> <!-- =========================================================================== -->
<target name="build-subprojects"/> <!-- Build all the applications -->
<target depends="init" name="build-project"> <!-- =========================================================================== -->
<target depends="init" name="build-lib">
<echo message="${ant.project.name}: ${ant.file}"/> <echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/classes" includeantruntime="false" source="${source}" target="${target}"> <javac debug="true" debuglevel="${debuglevel}" destdir="${result.classes.lib.dir}" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/> <src path="${source.lib.dir}"/>
<classpath refid="scenarium-logger.classpath"/> <classpath refid="io.scenarium.logger.classpath"/>
</javac> </javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/test-classes" includeantruntime="false" source="${source}" target="${target}"> </target>
<src path="test/src"/> <target depends="init" name="build-test">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${result.classes.test.dir}" includeantruntime="false" source="${source}" target="${target}">
<src path="${source.test.dir}"/>
<include name="**/*.java"/> <include name="**/*.java"/>
<classpath refid="scenarium-logger.classpath"/> <classpath refid="test.scenarium.logger.classpath"/>
</javac> </javac>
</target> </target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> <!-- =========================================================================== -->
<antcall target="build"/> <!-- Build all the applications -->
<!-- =========================================================================== -->
<target depends="build-lib,build-test" name="build">
</target> </target>
<target name="TestBasicLog">
<!-- =========================================================================== -->
<!-- javadoc generation -->
<!-- =========================================================================== -->
<target name="javadoc">
<javadoc destdir="${result.javadoc.dir}"
author="true"
version="true"
use="true"
windowtitle="Scenarium library API: ${ant.project.name}">
<fileset dir="${source.lib.dir}" defaultexcludes="yes">
<include name="io/scenarium/**"/>
</fileset>
<doctitle><![CDATA[<h1>Scenarium library: ${ant.project.name}</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright &#169; 2020 Scenarium. All Rights Reserved.</i>]]></bottom>
<!--
<tag name="todo" scope="all" description="To do:"/>
<group title="Group 1 Packages" packages="com.dummy.test.a*"/>
<group title="Group 2 Packages" packages="com.dummy.test.b*:com.dummy.test.c*"/>
<link offline="true" href="https://docs.oracle.com/javase/8/docs/api/" packagelistLoc="C:\tmp"/>
<link href="https://scenarium.io/"/>
-->
</javadoc>
</target>
<!-- =========================================================================== -->
<!-- package binary, source and javadoc in 3 jar -->
<!-- =========================================================================== -->
<target name="package-lib" depends="build" description="Package compile java in a jar">
<buildnumber />
<jar destfile="${result.jar.dir}/${ant.project.name}-${version}.jar" indexMetaInf="true" basedir="${result.classes.lib.dir}" />
</target>
<target name="package-src" description="Package sources in a jar">
<buildnumber />
<jar destfile="${result.jar.dir}/${ant.project.name}-${version}-sources.jar" basedir="${source.lib.dir}" />
</target>
<target name="package-javadoc" depends="javadoc" description="Package javadoc in a jar">
<buildnumber />
<jar destfile="${result.jar.dir}/${ant.project.name}-${version}-javadoc.jar" basedir="${result.javadoc.dir}" />
</target>
<target name="package" depends="package-lib,package-src,package-javadoc" description="generate all jar">
</target>
<!-- =========================================================================== -->
<!-- test the whole application -->
<!-- =========================================================================== -->
<target name="test">
<mkdir dir="${result.juint.dir}"/> <mkdir dir="${result.juint.dir}"/>
<jacoco:coverage destfile="${result.exec.file}"> <jacoco:coverage destfile="${result.coverage.work-file}">
<junit fork="yes" printsummary="withOutAndErr"> <junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/> <formatter type="xml"/>
<test name="test.scenarium.logger.TestBasicLog" todir="${result.juint.dir}"/> <test name="test.scenarium.logger.TestBasicLog" todir="${result.juint.dir}"/>
<jvmarg line="-ea"/> <jvmarg line="-ea"/>
<classpath refid="run.TestBasicLog.classpath"/> <classpath refid="test.scenarium.logger.classpath"/>
</junit> </junit>
</jacoco:coverage> </jacoco:coverage>
</target> </target>
<target name="test" depends="TestBasicLog"> <!-- creat all the test report -->
</target> <target name="report">
<target name="report" depends="test">
<!-- Step 3: Create coverage report --> <!-- Step 3: Create coverage report -->
<jacoco:report> <jacoco:report>
<!-- This task needs the collected execution data and ... --> <!-- This task needs the collected execution data and ... -->
<executiondata> <executiondata>
<file file="${result.exec.file}" /> <file file="${result.coverage.work-file}" />
</executiondata> </executiondata>
<!-- the class files and optional source files ... --> <!-- the class files and optional source files ... -->
<structure name="JaCoCo Ant Example"> <structure name="JaCoCo Ant Example">
<classfiles> <classfiles>
<fileset dir="${result.classes.dir}" /> <fileset dir="${result.classes.lib.dir}" />
</classfiles> </classfiles>
<sourcefiles encoding="UTF-8"> <sourcefiles encoding="UTF-8">
<fileset dir="src" /> <fileset dir="${source.lib.dir}" />
</sourcefiles> </sourcefiles>
</structure> </structure>
<!-- to produce reports in different formats. --> <!-- to produce reports in different formats. -->
<html destdir="${result.report.dir}" /> <html destdir="${result.coverage.report.dir}" />
<csv destfile="${result.report.dir}/report.csv" /> <csv destfile="${result.coverage.report.dir}/report.csv" />
<xml destfile="${result.report.dir}/report.xml" /> <xml destfile="${result.coverage.report.dir}/report.xml" />
</jacoco:report> </jacoco:report>
<junitreport todir="${result.juint.dir}"> <junitreport todir="${result.juint.dir}">
<fileset dir="${result.juint.dir}"> <fileset dir="${result.juint.dir}">
@ -148,7 +217,10 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
<report format="frames" todir="${result.juint.dir}"/> <report format="frames" todir="${result.juint.dir}"/>
</junitreport> </junitreport>
</target> </target>
<!-- =========================================================================== -->
<!-- generate by eclipse do not understand why --> <!-- generate by eclipse do not understand why -->
<!-- =========================================================================== -->
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler"> <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}"> <copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
@ -158,4 +230,8 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip> </unzip>
</target> </target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
</project> </project>