301 lines
14 KiB
XML
301 lines
14 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<project basedir="."
|
|
default="all"
|
|
name="scenarium-logger"
|
|
xmlns:jacoco="antlib:org.jacoco.ant"
|
|
xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant">
|
|
<property environment="env"/>
|
|
|
|
<!-- <property name="version" value="0.1.0" /> -->
|
|
<loadfile property="version" srcFile="version.txt"/>
|
|
<property name="title" value="Generic Scenarium Logger"/>
|
|
<property name="vendor" value="scenarium.io"/>
|
|
|
|
<property name="debuglevel" value="source,lines,vars"/>
|
|
<!-- configure dependency of JAVA -->
|
|
<property name="target" 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.jar.dir" location="${result.dir}/package" />
|
|
<property name="result.dependency.dir" location="${result.dir}/dependency" />
|
|
<property name="result.javadoc.dir" location="${result.dir}/javadoc" />
|
|
<property name="result.juint.dir" location="${result.dir}/junit" />
|
|
<property name="result.classes.lib.dir" location="${result.dir}/classes-lib" />
|
|
<property name="result.classes.test.dir" location="${result.dir}/classes-test" />
|
|
<property name="result.coverage.report.dir" location="${result.dir}/coverage/site" />
|
|
<property name="result.coverage.work-file" location="${result.dir}/coverage/jacoco.exec" />
|
|
|
|
<property name="extern.junit.dir" value="${user.home}/extern/lib/"/>
|
|
<property name="extern.jacoco.dir" value="${user.home}/extern/jacoco/"/>
|
|
<property name="extern.checkstyle.dir" value="${user.home}/extern/checkstyle/"/>
|
|
|
|
<!-- https://www.eclemma.org/jacoco/ -->
|
|
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
|
|
<classpath path="${extern.jacoco.dir}/jacocoant.jar" />
|
|
</taskdef>
|
|
<!-- https://checkstyle.sourceforge.io/anttask.html -->
|
|
|
|
<taskdef uri="antlib:com.puppycrawl.tools.checkstyle.ant" resource="com/puppycrawl/tools/checkstyle/ant/antlib.xml">
|
|
<classpath path="${extern.checkstyle.dir}/checkstyle-all.jar" />
|
|
</taskdef>
|
|
<!--
|
|
mkdir -p ~/extern/jacoco
|
|
wget http://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.5/jacoco-0.8.5.zip -O /tmp/jacoco.zip
|
|
unzip -d /tmp/jacoco_unzip /tmp/jacoco.zip
|
|
mv /tmp/jacoco_unzip/lib/*.jar ~/extern/jacoco
|
|
rm -rf /tmp/jacoco_unzip /tmp/jacoco.zip
|
|
|
|
mkdir -p ~/extern/checkstyle
|
|
wget https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.36/checkstyle-8.36-all.jar -O ~/extern/checkstyle/checkstyle-all.jar
|
|
|
|
mkdir -p ~/extern/lib
|
|
wget https://repo1.maven.org/maven2/org/junit/platform/junit-platform-commons/1.6.2/junit-platform-commons-1.6.2.jar -O ~/extern/lib/junit-platform-commons.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/platform/junit-platform-engine/1.6.2/junit-platform-engine-1.6.2.jar -O ~/extern/lib/junit-platform-engine.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/platform/junit-platform-launcher/1.6.2/junit-platform-launcher-1.6.2.jar -O ~/extern/lib/junit-platform-launcher.jar
|
|
wget https://repo1.maven.org/maven2/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar -O ~/extern/lib/opentest4j.jar
|
|
wget https://repo1.maven.org/maven2/junit/junit/4.13/junit-4.13.jar -O ~/extern/lib/junit.jar
|
|
wget https://repo1.maven.org/maven2/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar -O ~/extern/lib/apiguardian-api.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/5.6.2/junit-jupiter-api-5.6.2.jar -O ~/extern/lib/junit-jupiter-api.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-engine/5.6.2/junit-jupiter-engine-5.6.2.jar -O ~/extern/lib/junit-jupiter-engine.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/vintage/junit-vintage-engine/5.6.2/junit-vintage-engine-5.6.2.jar -O ~/extern/lib/junit-vintage-engine.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-params/5.6.2/junit-jupiter-params-5.6.2.jar -O ~/extern/lib/junit-jupiter-params.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/platform/junit-platform-runner/1.6.2/junit-platform-runner-1.6.2.jar -O ~/extern/lib/junit-platform-runner.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-migrationsupport/5.6.2/junit-jupiter-migrationsupport-5.6.2.jar -O ~/extern/lib/junit-jupiter-migrationsupport.jar
|
|
wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar -O ~/extern/lib/hamcrest-core.jar
|
|
wget https://repo1.maven.org/maven2/org/junit/platform/junit-platform-suite-api/1.6.2/junit-platform-suite-api-1.6.2.jar -O ~/extern/lib/junit-platform-suite-api.jar
|
|
wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar -O ~/extern/lib/hamcrest-core.jar
|
|
-->
|
|
<path id="junit.classpath">
|
|
<!-- keep all lib in this directiry-->
|
|
<fileset dir="${extern.junit.dir}"/>
|
|
<!--
|
|
<pathelement location="${basedir}/junit-jupiter-api-5.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-jupiter-engine-5.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-jupiter-migrationsupport-5.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-jupiter-params-5.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-platform-commons-1.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-platform-engine-1.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-platform-launcher-1.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-jupiter-runner-5.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-platform-suite-api-1.6.2.jar"/>
|
|
<pathelement location="${basedir}/junit-vintage-engine-5.6.2.jar"/>
|
|
<pathelement location="${basedir}/opentest4j-1.2.0.jar"/>
|
|
<pathelement location="${basedir}/apiguardian-api-1.1.0.jar"/>
|
|
<pathelement location="${basedir}/junit-4.13.jar"/>
|
|
<pathelement location="${basedir}/hamcrest-core-1.3.jar"/>
|
|
-->
|
|
</path>
|
|
<path id="dependency.modulepath">
|
|
<pathelement location="${result.dependency.dir}"/>
|
|
</path>
|
|
<path id="library.classpath">
|
|
<pathelement location="${result.classes.lib.dir}"/>
|
|
</path>
|
|
<path id="test.classpath">
|
|
<path refid="library.classpath"/>
|
|
<pathelement location="${result.classes.test.dir}"/>
|
|
<path refid="junit.classpath"/>
|
|
</path>
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- clean all the build-tree -->
|
|
<!-- =========================================================================== -->
|
|
<target name="clean">
|
|
<delete dir="${result.dir}/"/>
|
|
</target>
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- Coding stryle verification -->
|
|
<!-- =========================================================================== -->
|
|
<target name="style">
|
|
<cs:checkstyle config="CheckStyle.xml"
|
|
failureProperty="checkstyle.failure"
|
|
failOnViolation="true">
|
|
<!--<formatter type="xml" tofile="checkstyle_report.xml"/>-->
|
|
<fileset dir="${source.lib.dir}" includes="**/*.java"/>
|
|
<fileset dir="${source.test.dir}" includes="**/*.java"/>
|
|
</cs:checkstyle>
|
|
</target>
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- initialize the build system -->
|
|
<!-- =========================================================================== -->
|
|
<target name="init">
|
|
<mkdir dir="${result.classes.lib.dir}"/>
|
|
<mkdir dir="${result.classes.test.dir}"/>
|
|
<mkdir dir="${result.dependency.dir}"/>
|
|
<copy includeemptydirs="false" todir="${result.classes.lib.dir}">
|
|
<fileset dir="${source.lib.dir}">
|
|
<exclude name="**/*.launch"/>
|
|
<exclude name="**/*.java"/>
|
|
</fileset>
|
|
</copy>
|
|
<copy includeemptydirs="false" todir="${result.classes.test.dir}">
|
|
<fileset dir="${source.test.dir}">
|
|
<include name="**/*.java"/>
|
|
<exclude name="**/*.launch"/>
|
|
<exclude name="**/*.java"/>
|
|
</fileset>
|
|
</copy>
|
|
</target>
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- Build all the applications -->
|
|
<!-- =========================================================================== -->
|
|
<target depends="init" name="build-lib">
|
|
<echo message="${ant.project.name}: ${ant.file}"/>
|
|
<javac debug="true" debuglevel="${debuglevel}" destdir="${result.classes.lib.dir}" includeantruntime="false" source="${source}" target="${target}">
|
|
<src path="${source.lib.dir}"/>
|
|
<classpath refid="library.classpath"/>
|
|
</javac>
|
|
</target>
|
|
<target depends="build-lib" 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"/>
|
|
<classpath refid="test.classpath"/>
|
|
<modulepath refid="dependency.modulepath"/>
|
|
</javac>
|
|
</target>
|
|
|
|
<!-- Build all the applications -->
|
|
<target depends="build-lib,build-test" name="build">
|
|
</target>
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- test the whole application -->
|
|
<!-- =========================================================================== -->
|
|
<target name="test">
|
|
<mkdir dir="${result.juint.dir}"/>
|
|
<jacoco:coverage destfile="${result.coverage.work-file}">
|
|
<junit fork="yes" printsummary="withOutAndErr">
|
|
<formatter type="xml"/>
|
|
<test name="test.scenarium.logger.TestBasicLog" todir="${result.juint.dir}"/>
|
|
<jvmarg line="-ea"/>
|
|
<classpath refid="test.classpath"/>
|
|
<modulepath refid="dependency.modulepath"/>
|
|
</junit>
|
|
</jacoco:coverage>
|
|
</target>
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- javadoc generation -->
|
|
<!-- =========================================================================== -->
|
|
<target name="javadoc">
|
|
<javadoc destdir="${result.javadoc.dir}"
|
|
author="true"
|
|
version="true"
|
|
use="true"
|
|
windowtitle="Scenarium library API: ${ant.project.name}">
|
|
<modulepath refid="dependency.modulepath"/>
|
|
|
|
<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 © 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>
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- Create the junit and coverage report -->
|
|
<!-- =========================================================================== -->
|
|
<!-- creat all the test report -->
|
|
<target name="report">
|
|
<!-- Step 3: Create coverage report -->
|
|
<jacoco:report>
|
|
<!-- This task needs the collected execution data and ... -->
|
|
<executiondata>
|
|
<file file="${result.coverage.work-file}" />
|
|
</executiondata>
|
|
<!-- the class files and optional source files ... -->
|
|
<structure name="JaCoCo Ant Example">
|
|
<classfiles>
|
|
<fileset dir="${result.classes.lib.dir}" />
|
|
</classfiles>
|
|
<sourcefiles encoding="UTF-8">
|
|
<fileset dir="${source.lib.dir}" />
|
|
</sourcefiles>
|
|
</structure>
|
|
<!-- to produce reports in different formats. -->
|
|
<html destdir="${result.coverage.report.dir}" />
|
|
<csv destfile="${result.coverage.report.dir}/report.csv" />
|
|
<xml destfile="${result.coverage.report.dir}/report.xml" />
|
|
</jacoco:report>
|
|
<junitreport todir="${result.juint.dir}">
|
|
<fileset dir="${result.juint.dir}">
|
|
<include name="TEST-*.xml"/>
|
|
</fileset>
|
|
<report format="frames" todir="${result.juint.dir}"/>
|
|
</junitreport>
|
|
</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}">
|
|
<manifest>
|
|
<section name="common">
|
|
<attribute name="Specification-Title" value="${title}" />
|
|
<attribute name="Specification-Version" value="${version}" />
|
|
<attribute name="Specification-Vendor" value="${vendor}" />
|
|
<attribute name="Implementation-Title" value="${title}" />
|
|
<attribute name="Implementation-Version" value="${version}" />
|
|
<attribute name="Implementation-Vendor" value="${vendor}" />
|
|
</section>
|
|
</manifest>
|
|
</jar>
|
|
</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>
|
|
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- do all the jobs -->
|
|
<!-- =========================================================================== -->
|
|
<target name="all" depends="clean,style,build,test,javadoc,report,package">
|
|
</target>
|
|
|
|
|
|
|
|
<!-- =========================================================================== -->
|
|
<!-- generate by eclipse do not understand why -->
|
|
<!-- =========================================================================== -->
|
|
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
|
|
<copy todir="${ant.library.dir}">
|
|
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
|
|
</copy>
|
|
<unzip dest="${ant.library.dir}">
|
|
<patternset includes="jdtCompilerAdapter.jar"/>
|
|
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
|
|
</unzip>
|
|
</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>
|