Merge branch 'dev' into 'master'
This commit is contained in:
commit
b6a267719d
12
.classpath
12
.classpath
@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<classpathentry kind="src" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="test/src">
|
||||
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
@ -15,6 +15,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
@ -23,10 +24,5 @@
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
<classpathentry kind="output" path="out/eclipse/classes"/>
|
||||
</classpath>
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -9,5 +9,9 @@ ScenariumConfig.txt
|
||||
*.class
|
||||
*~
|
||||
*.bck
|
||||
|
||||
build.number
|
||||
/extern/
|
||||
/out/
|
||||
/.settings/
|
||||
/junit/
|
||||
/target/
|
||||
|
@ -2,63 +2,27 @@ image: heeroyui/scenarium-gitlabci:latest
|
||||
|
||||
variables:
|
||||
JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF8"
|
||||
#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/
|
||||
- ant -version
|
||||
|
||||
stages:
|
||||
- style
|
||||
- build
|
||||
- test
|
||||
- package
|
||||
- all
|
||||
|
||||
style_job:
|
||||
stage: style
|
||||
ant_job:
|
||||
stage: all
|
||||
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
|
||||
- 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
|
||||
- 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:
|
||||
- target/site/jacoco
|
||||
- out/ant/coverage/site
|
||||
- out/ant/package
|
||||
reports:
|
||||
junit: target/surefire-reports/TEST-*.xml
|
||||
#cobertura: target/site/cobertura/coverage.xml
|
||||
junit: out/ant/junit/TEST-*.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
|
6
.project
6
.project
@ -16,14 +16,8 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
|
300
build.xml
Normal file
300
build.xml
Normal file
@ -0,0 +1,300 @@
|
||||
<?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>
|
152
pom.xml
152
pom.xml
@ -1,152 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.scenarium</groupId>
|
||||
<artifactId>logger</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.1.0</version>
|
||||
<name>Scenarium logger</name>
|
||||
<description>Scenarium generic logger interface to store and inspect in runtime</description>
|
||||
<url>https://scenarium.io</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Mozilla Public License Version 2.0</name>
|
||||
<url>https://www.mozilla.org/en-US/MPL/2.0/</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>https://gitlab.com/scenarium/scenarium-logger</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test/src</testSourceDirectory>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>test/src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<plugins>
|
||||
<!-- Build the application or the library or the plug-in -->
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>14</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Create the source bundle -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- junit results -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
<!-- Create coverage -->
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!-- attached to Maven test phase -->
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Java-doc generation for stand-alone site -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<show>private</show>
|
||||
<nohelp>true</nohelp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Check the style of the code -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<configLocation>CheckStyle.xml</configLocation>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<failsOnError>true</failsOnError>
|
||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<lineEnding>LF</lineEnding>
|
||||
<configFile>Formatter.xml</configFile>
|
||||
<directories>
|
||||
<directory>src/</directory>
|
||||
<directory>test/src</directory>
|
||||
</directories>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>validate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Generate Java-docs As Part Of Project Reports -->
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<!--<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>-->
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
@ -53,49 +53,68 @@ public class Logger {
|
||||
private static boolean haveColor = false;
|
||||
private static boolean isInit = false;
|
||||
|
||||
private Logger() {}
|
||||
static {
|
||||
// Load system color state
|
||||
String value = System.getProperty("logger.color");
|
||||
if (value != null)
|
||||
if (value.contentEquals("true") || value.contentEquals("1"))
|
||||
haveColor = true;
|
||||
else if (value.contentEquals("false") || value.contentEquals("0"))
|
||||
haveColor = false;
|
||||
else
|
||||
System.out.println("error in color state '" + value + "' ==> not in range [true, false, 0, 1]");
|
||||
|
||||
public static void usage(String applicationName) {
|
||||
Log.print("logger - help : ");
|
||||
Log.print(" " + applicationName + " [options]");
|
||||
Log.print(" --logger-level= Change the default log level (set all Log level):");
|
||||
Log.print(" -3: debug None");
|
||||
Log.print(" -2: debug Print");
|
||||
Log.print(" -1: debug Todo");
|
||||
Log.print(" 0: debug Critical (default)");
|
||||
Log.print(" 1: debug Error");
|
||||
Log.print(" 2: debug Warning");
|
||||
Log.print(" 3: debug Info (default in debug)");
|
||||
Log.print(" 4: debug Debug");
|
||||
Log.print(" 5: debug Verbose");
|
||||
Log.print(" --logger-lib=name:X Set a library specific level:");
|
||||
Log.print(" name Name of the library");
|
||||
Log.print(" X Log level to set [0..6]");
|
||||
Log.print(" note: ':' can be replace with '/' or '+'");
|
||||
Log.print(" --logger-color Enable color in log (default in Linux/debug)");
|
||||
Log.print(" --logger-no-color Disable color in log (default in Linux/release and Other)");
|
||||
Log.print(" -h/--help: Display this help");
|
||||
Log.print(" example:");
|
||||
Log.print(" " + applicationName + " --logger-color --logger-level=2 --logger-lib=etk:5 --logger-lib=appl:5");
|
||||
// Load system debug level
|
||||
value = System.getProperty("logger.level");
|
||||
if (value != null) {
|
||||
LogLevel level = LogLevel.fromString(value);
|
||||
System.out.println("Change global level at " + value + " ==> " + level);
|
||||
Logger.defaultLevel = level;
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(String applicationName, List<String> args) {
|
||||
private Logger() {}
|
||||
|
||||
public static void usage() {
|
||||
Log.print(" [log]: Log session interface");
|
||||
Log.print(" --log-level= Change the default log level (set all Log level):");
|
||||
Log.print(" -3/none: debug None");
|
||||
Log.print(" -2/print: debug Print");
|
||||
Log.print(" -1/todo: debug Todo");
|
||||
Log.print(" 0/critical: debug Critical (default)");
|
||||
Log.print(" 1/error: debug Error");
|
||||
Log.print(" 2/warning: debug Warning");
|
||||
Log.print(" 3/info: debug Info");
|
||||
Log.print(" 4/debug: debug Debug");
|
||||
Log.print(" 5/verbose: debug Verbose");
|
||||
Log.print(" --log-lib=name:X Set a library specific level:");
|
||||
Log.print(" name Name of the library");
|
||||
Log.print(" X Log level to set [0..6]");
|
||||
Log.print(" !note!: ':' can be replace with '/' or '+'");
|
||||
Log.print(" --log-color Enable color in log");
|
||||
Log.print(" --log-no-color Disable color in log (default)");
|
||||
Log.print("");
|
||||
}
|
||||
|
||||
/** Initialize the library with generic argument in command line
|
||||
* @param args list of argument that are filtered after */
|
||||
public static void init(List<String> args) {
|
||||
if (isInit)
|
||||
return;
|
||||
isInit = true;
|
||||
for (int iii = 0; iii < args.size(); ++iii) {
|
||||
String data = args.get(iii);
|
||||
if (data.startsWith("--logger-level=")) {
|
||||
String value = data.substring(15);
|
||||
if (data.startsWith("--log-level=")) {
|
||||
String value = data.substring(12);
|
||||
LogLevel level = LogLevel.fromString(value);
|
||||
System.out.println("Change global level at " + value + " ==> " + level);
|
||||
Logger.defaultLevel = level;
|
||||
} else if (data.contentEquals("--logger-color"))
|
||||
} else if (data.contentEquals("--log-color"))
|
||||
Logger.haveColor = true;
|
||||
else if (data.contentEquals("--logger-no-color"))
|
||||
else if (data.contentEquals("--log-no-color"))
|
||||
Logger.haveColor = false;
|
||||
else if (data.startsWith("--logger-lib=")) {
|
||||
String value = data.substring(13);
|
||||
else if (data.startsWith("--log-lib=")) {
|
||||
String value = data.substring(10);
|
||||
String[] values = value.split("/");
|
||||
if (values.length != 2) {
|
||||
values = value.split(":");
|
||||
@ -109,16 +128,13 @@ public class Logger {
|
||||
}
|
||||
System.out.println("Change level of '" + values[0] + "' at " + LogLevel.fromString(values[1]));
|
||||
logLevels.put(values[0], LogLevel.fromString(values[1]));
|
||||
} else if (data.contentEquals("-h") || data.contentEquals("--help"))
|
||||
usage(applicationName);
|
||||
else if (data.startsWith("--logger"))
|
||||
Log.error("Can not parse the argument : '" + data + "'");
|
||||
}
|
||||
}
|
||||
// Clear all logger elements.
|
||||
int iii = 0;
|
||||
while (iii < args.size()) {
|
||||
String data = args.get(iii);
|
||||
if (data.startsWith("--logger"))
|
||||
if (data.startsWith("--log"))
|
||||
args.remove(iii);
|
||||
else
|
||||
iii++;
|
||||
|
@ -13,9 +13,10 @@ import java.util.List;
|
||||
|
||||
import io.scenarium.logger.Logger;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
@ -23,34 +24,33 @@ public class TestBasicLog {
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void firstInitialisation() {
|
||||
public void aaFirstInitialisation() {
|
||||
List<String> args = new ArrayList<>();
|
||||
args.add("--logger-level=999");
|
||||
args.add("--logger-level=1");
|
||||
args.add("--logger-no-color");
|
||||
args.add("--logger-color");
|
||||
args.add("--logger-lib=sc-log-test+6");
|
||||
args.add("--logger-lib=sc-log-test/6");
|
||||
args.add("--logger-lib=sc-log-test:6");
|
||||
args.add("--logger-lib=sc-log-test:verbose");
|
||||
args.add("--logger-lib=sc-log-test2+3");
|
||||
args.add("--logger-lib=sc-log-test");
|
||||
args.add("--logger-with-stupid-parameter=sdkfjsqdlkf");
|
||||
args.add("--log-level=999");
|
||||
args.add("--log-level=1");
|
||||
args.add("--log-no-color");
|
||||
args.add("--log-color");
|
||||
args.add("--log-lib=sc-log-test+6");
|
||||
args.add("--log-lib=sc-log-test/6");
|
||||
args.add("--log-lib=sc-log-test:6");
|
||||
args.add("--log-lib=sc-log-test:verbose");
|
||||
args.add("--log-lib=sc-log-test2+3");
|
||||
args.add("--log-lib=sc-log-test");
|
||||
args.add("--log-with-stupid-parameter=sdkfjsqdlkf");
|
||||
args.add("--help");
|
||||
Logger.init(TestBasicLog.class.getCanonicalName(), args);
|
||||
Logger.init(args);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void secondInitialisation() {
|
||||
public void bbSecondInitialisation() {
|
||||
List<String> args = new ArrayList<>();
|
||||
Logger.init(TestBasicLog.class.getCanonicalName(), args);
|
||||
|
||||
Logger.init(args);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void basicLogCall() {
|
||||
public void ccBasicLogCall() {
|
||||
Log.print("Simple print");
|
||||
Log.todo("Simple todo");
|
||||
Log.error("Simple error");
|
||||
@ -90,8 +90,14 @@ public class TestBasicLog {
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void testSimpleLog() {
|
||||
public void ddTestSimpleLog() {
|
||||
testLog();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void eeUsage() {
|
||||
Logger.usage();
|
||||
}
|
||||
|
||||
}
|
||||
|
1
version.txt
Normal file
1
version.txt
Normal file
@ -0,0 +1 @@
|
||||
0.1.0-dev
|
Loading…
x
Reference in New Issue
Block a user