[DEV] update for ant

This commit is contained in:
Edouard DUPIN 2020-09-07 00:56:32 +02:00
parent 3966c55232
commit 89b968393b
2 changed files with 117 additions and 97 deletions

View File

@ -5,60 +5,42 @@ variables:
#JAVA_HOME: "/usr/lib/jvm/java-14-openjdk/"
before_script:
#- apk update && apk add python3 gawk
- which javac
- javac --version
- mvn --version
cache:
paths:
- .m2/repository/
- target/
stages:
- style
- build
- test
- package
- ant
- maven
style_job:
stage: style
ant_job:
stage: ant
script:
- ant all
#- awk -F, '{ instructions += $4 + $5; covered += $5 } END { print "===============================================\nCoverage Results:\n\n", covered, " / ", instructions, " instructions covered"; print "Total", 100*covered/instructions, "% covered\n==\n===============================================" }' out/coverage/site/jacoco.csv
artifacts:
when: on_success
expire_in: 3 day
paths:
- out/coverage/site
- out/package
reports:
junit: out/junit/TEST-*.xml
maven_job:
stage: maven
script:
- mvn $MAVEN_CLI_OPTS checkstyle:checkstyle
- mvn $MAVEN_CLI_OPTS formatter:validate
build_job:
stage: build
dependencies:
- style_job
script:
- mvn $MAVEN_CLI_OPTS compile
test_job:
stage: test
dependencies:
- build_job
script:
- mvn $MAVEN_CLI_OPTS test
#- mkdir -p target/site/cobertura && /usr/bin/python3 ./cover2cover.py target/site/jacoco/jacoco.xml src/io/scenarium/logger/ > target/site/cobertura/coverage.xml
- mvn $MAVEN_CLI_OPTS -Dmaven.test.skip=true compile package javadoc:javadoc javadoc:jar
- awk -F, '{ instructions += $4 + $5; covered += $5 } END { print "===============================================\nCoverage Results:\n\n", covered, " / ", instructions, " instructions covered"; print "Total", 100*covered/instructions, "% covered\n==\n===============================================" }' target/site/jacoco/jacoco.csv
artifacts:
when: on_success
expire_in: 3 day
paths:
- target/site/jacoco
- target/*.jar
reports:
junit: target/surefire-reports/TEST-*.xml
#cobertura: target/site/cobertura/coverage.xml
package_job:
stage: package
dependencies:
- test_job
script:
- mvn $MAVEN_CLI_OPTS -Dmaven.test.skip=true compile package javadoc:javadoc javadoc:jar
artifacts:
when: on_success
expire_in: 3 day
paths:
- target/*.jar

156
build.xml
View File

@ -1,5 +1,9 @@
<?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="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" />
@ -12,7 +16,7 @@
<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/" />
<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" />
@ -20,12 +24,20 @@
<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" />
<!-- Import JaCoCo Ant tasks -->
<!-- https://www.eclemma.org/jacoco/-->
<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="${basedir}/extern/jacoco/jacocoant.jar" />
<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>
<property name="libPath" value="${basedir}/extern/lib/"/> <!--value="${user.home}"-->
<!--
mkdir -p extern/lib
cd extern/lib
@ -44,10 +56,15 @@ wget https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-migrationsup
wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.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
wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
cd ../../
mkdir -p extern/checkstyle
cd extern/checkstyle
wget https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.36/checkstyle-8.36-all.jar
cd ../../
-->
<path id="junit.classpath">
<!-- keep all lib in this directiry-->
<fileset dir="${libPath}"/>
<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"/>
@ -74,6 +91,26 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
<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 -->
<!-- =========================================================================== -->
@ -95,13 +132,6 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
</copy>
</target>
<!-- =========================================================================== -->
<!-- clean all the build-tree -->
<!-- =========================================================================== -->
<target name="clean">
<delete dir="${result.dir}/"/>
</target>
<!-- =========================================================================== -->
<!-- Build all the applications -->
<!-- =========================================================================== -->
@ -121,12 +151,25 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
</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.scenarium.logger.classpath"/>
</junit>
</jacoco:coverage>
</target>
<!-- =========================================================================== -->
<!-- javadoc generation -->
<!-- =========================================================================== -->
@ -153,6 +196,39 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
</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 -->
<!-- =========================================================================== -->
@ -171,53 +247,15 @@ wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core
<target name="package" depends="package-lib,package-src,package-javadoc" description="generate all jar">
</target>
<!-- =========================================================================== -->
<!-- test the whole application -->
<!-- do all the jobs -->
<!-- =========================================================================== -->
<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.scenarium.logger.classpath"/>
</junit>
</jacoco:coverage>
</target>
<!-- 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 name="all" depends="clean,style,build,test,javadoc,report,package">
</target>
<!-- =========================================================================== -->
<!-- generate by eclipse do not understand why -->
<!-- =========================================================================== -->