Added Ant build. Improved resources files.

This commit is contained in:
Christian P. MOMON 2018-01-06 02:18:34 +01:00
parent 4ad75d995c
commit 2e15c98bd4
15 changed files with 293 additions and 36 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
/conf.xml /conf.xml
/target /target
/bin/ /bin/
/dist/
/build/

View File

@ -7,7 +7,7 @@
* Place internal classes in their own file. * Place internal classes in their own file.
* Renamed package from fr.imirhil.april to org.april * Renamed package from fr.imirhil.april to org.april
* Splitted launcher and CLI. * Splitted launcher and CLI.
* change Java version to 1.8
* anonymized Twitter API key * anonymized Twitter API key
* eplaced Maven with Ant * eplaced Maven with Ant

174
build-appjar.xml Normal file
View File

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="main" name="Build-appjar">
<!--ANT 1.7 is required -->
<property name="buildjar.version" value="1.8" />
<property file="build.properties" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.src" value="${basedir}/src" />
<property name="build.classes" value="${build.dir}/classes" />
<property name="build.javadoc" value="${build.dir}/javadoc" />
<property name="test.src" value="${basedir}/test" />
<property name="test.classes" value="${build.dir}/test-classes" />
<property name="debug" value="on" />
<path id="project.libs">
<fileset dir="${basedir}/lib" includes="**/*.jar" excludes="*sources* *src*" />
<!--fileset dir="${basedir}/lib/Logs" includes="**.jar" excludes="*sources* *src*" /-->
</path>
<property name="classpath.absolute" value="${toString:project.libs}" />
<manifestclasspath property="classpath.relative" jarfile="hebdobot.jar">
<classpath refid="project.libs" />
</manifestclasspath>
<!-- ***** Main ***** -->
<target name="main" description="Manage distribution build" depends="dist, clean">
<echo>Done.</echo>
</target>
<!-- ***** Help ***** -->
<target name="help" description="Display detailed usage information">
<echo>Type ant -p</echo>
</target>
<!-- ***** Clear ***** -->
<target name="clear" description="Clear temporary directories before work">
<delete dir="${build.dir}" />
</target>
<!-- ***** Clean ***** -->
<target name="clean" description="Clear temporary directories after work">
<delete dir="${build.dir}" />
</target>
<!-- ***** Compile ***** -->
<target name="compile" description="Compile project">
<delete dir="${build.classes}" />
<mkdir dir="${build.classes}" />
<echo>classpath=${toString:project.libs}</echo>
<javac srcdir="${build.src}" destdir="${build.classes}" classpath="${toString:project.libs}" debug="${debug}" deprecation="on" includeantruntime="no" />
</target>
<!-- ***** copy stuff ***** -->
<target name="copysourcestuff" description="Copy source files other than Java">
<copy todir="${build.classes}">
<fileset dir="${build.src}" excludes="**/*.java" />
</copy>
</target>
<!-- ***** JavaDoc ***** -->
<target name="javadoc" description="Javadoc construction">
<javadoc sourcepath="${build.src}" destdir="${build.javadoc}">
<classpath>
<fileset dir="lib" includes="**/*.jar" />
</classpath>
</javadoc>
</target>
<!-- ***** Dist ***** -->
<target name="dist" description="Build distribution directory" depends="clear,compile,copysourcestuff,javadoc">
<!--echo message="==========>Build Classpath: ${classpath.absolute}" /-->
<!--echo message="==========>Manifest Classpath: ${classpath.relative}" /-->
<!-- AUTOMATIC MANAGEMENT -->
<buildnumber file="build.num" description="Id of the build"/>
<property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}" />
<property name="dist.name" value="${product.name}-${dist.version}" />
<property name="dist.dir" value="${basedir}/dist/${product.name}-${dist.version}" />
<tstamp>
<format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" />
</tstamp>
<!-- -->
<delete dir="${dist.dir}" />
<mkdir dir="${dist.dir}"/>
<!-- Update build_information.properties file -->
<property name="build.information.file" value="${build.dir}/build_information.properties" />
<propertyfile file="${build.information.file}" >
<entry key="product.name" value="${product.name}"/>
<entry key="product.revision.major" value="${product.revision.major}"/>
<entry key="product.revision.minor" value="${product.revision.minor}"/>
<entry key="product.revision.build" value="${build.number}"/>
<entry key="product.revision.date" type="date" value="now"/>
<entry key="product.revision.generator" value="Ant"/>
<entry key="product.revision.author" value="${user.name}"/>
</propertyfile>
<!-- Build the jar file list. -->
<!-- Package jar -->
<property name="dist.jar" value="${dist.dir}/${product.name}.jar" />
<jar destfile="${dist.jar}">
<restrict>
<name regex=".*/*\.(class|pom|properties|xsd)"/>
<archives>
<zips>
<fileset dir="${basedir}/lib" includes="**/*.jar" excludes="*sources* *src*" />
</zips>
</archives>
</restrict>
<manifest>
<attribute name="Built-By" value="${user.name} using ant" />
<attribute name="Built-Date" value="${dist.time}" />
<attribute name="Main-Class" value = "org.april.hebdobot.HebdobotLauncher"/>
</manifest>
<fileset dir="${build.classes}" />
<!--zipfileset dir="${basedir}/lib" includes="${toString:project.libs}" /-->
</jar>
<!-- Package sources -->
<property name="dist.srczip" value="${dist.dir}/${dist.name}-sources.zip" />
<zip destfile="${dist.srczip}" update="true" preserve0permissions="true">
<fileset dir="${build.src}" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</zip>
<!-- Package Javadoc -->
<property name="dist.javadoc.zip" value="${dist.dir}/${dist.name}-javadoc.zip" />
<zip destfile="${dist.javadoc.zip}" update="true">
<fileset dir="${build.javadoc}" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</zip>
<!-- Copy stuff -->
<copy file="resources/scripts/${product.name}.sh" todir="${dist.dir}/" overwrite="true" />
<chmod file="${dist.dir}/${product.name}.sh" perm="ugo+rx" />
<copy file="LICENSE" todir="${dist.dir}/" overwrite="true" failonerror="false" />
<copy file="README" todir="${dist.dir}/" overwrite="true" failonerror="false" />
<copy file="README.md" todir="${dist.dir}/" overwrite="true" failonerror="false" />
<!--copy file="scripts/log4j.properties" todir="${dist.dir}/" overwrite="true" /-->
<mkdir dir="${dist.dir}/conf" />
<copy todir="${dist.dir}/conf">
<fileset dir="${basedir}/resources/conf" includes="*" />
</copy>
<mkdir dir="${dist.dir}/man"/>
<copy todir="${dist.dir}/man">
<fileset dir="${basedir}/resources/man" includes="*" />
</copy>
<delete file="${build.information.file}" />
</target>
<!-- ***** Build and GIT ***** -->
<target name="buildandgit" depends="dist,clean">
<echo message="Commit build.num" />
<exec executable="git" outputproperty="git.commit.out" failifexecutionfails="true">
<arg line="commit -m 'Build ${dist.version}' build.num" />
</exec>
<echo message="${git.commit.out}" />
<echo message="Tag" />
<exec executable="git" outputproperty="git.tag.out" failifexecutionfails="true">
<arg line="tag -a ${dist.version} -m 'Build ${dist.version}'" />
</exec>
<echo message="${git.tag.out}" />
<echo message="Push" />
<exec executable="git" outputproperty="git.push.out" failifexecutionfails="true">
<arg line="push --follow-tags" />
</exec>
<echo message="${git.push.out}" />
</target>
</project>

3
build.num Normal file
View File

@ -0,0 +1,3 @@
#Build Number for ANT. Do not edit!
#Sat Jan 06 02:22:43 CET 2018
build.number=0

3
build.properties Normal file
View File

@ -0,0 +1,3 @@
product.name=hebdobot
product.revision.major=2
product.revision.minor=0

40
build.sh Executable file
View File

@ -0,0 +1,40 @@
#/bin/bash
echo "Hebdobot build"
okCount=0
# Ant check.
antCheck=`which ant`
if [[ "$antCheck" =~ ^/.* ]]; then
echo "Ant requirement................ OK"
let "okCount+=1"
else
echo "Ant requirement................ MISSING"
fi
# Javac check.
javacCheck=`which javac`
if [[ "$javacCheck" =~ ^/.* ]]; then
echo "Javac requirement.............. OK"
let "okCount+=1"
else
echo "Javac requirement.............. MISSING"
fi
# Java version check.
javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 8 version requirement..... OK"
let "okCount+=1"
else
echo "Java 8 version requirement..... MISSING"
fi
if [ "$okCount" == 3 ]; then
echo "Requirement OK"
ant -f build.xml
else
echo "Requirement MISSING, build abort"
fi

5
build.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="dist" name="Build">
<!-- -->
<import file="build-appjar.xml" />
</project>

5
buildandgit.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="buildandgit" name="BuildAndGit">
<!-- -->
<import file="build-appjar.xml" />
</project>

View File

@ -15,7 +15,7 @@ NAME=hebdobot
BASE_DIR=/srv/$NAME BASE_DIR=/srv/$NAME
PID_FILE=$BASE_DIR/$NAME.pid PID_FILE=$BASE_DIR/$NAME.pid
DAEMON=$(which java) DAEMON=$(which java)
DAEMON_ARGS="-cp *:lib/* fr.imirhil.april.hebdobot.Application" DAEMON_ARGS=""
CMD="/sbin/start-stop-daemon --chdir $BASE_DIR --quiet --make-pidfile --pidfile $PID_FILE --exec $DAEMON" CMD="/sbin/start-stop-daemon --chdir $BASE_DIR --quiet --make-pidfile --pidfile $PID_FILE --exec $DAEMON"
case "$1" in case "$1" in

View File

@ -7,3 +7,33 @@ log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = %d %-5p %c - %m%n log4j.appender.stdout.layout.ConversionPattern = %d %-5p %c - %m%n
#log4j.appender.CONSOLE.layout.ConversionPattern = %d{ISO8601} - Hebdobot [%-5p] %34.34c.%25M - %m%n #log4j.appender.CONSOLE.layout.ConversionPattern = %d{ISO8601} - Hebdobot [%-5p] %34.34c.%25M - %m%n
# Log information (priority setting : DEBUG < INFO < WARN < ERROR)
# ################
log4j.rootLogger = INFO, RSLisi-Writer, CONSOLE
log4j.logger.fr.devinsy.hico = DEBUG
log4j.logger.fr.devinsy.kiss4web = DEBUG
log4j.logger.fr.devinsy.xidyn = INFO
log4j.logger.fr.devinsy.xidyn.Presenter = INFO
log4j.logger.fr.devinsy.xidyn.FilePresenter = DEBUG
log4j.logger.eu.republiquesociale = DEBUG
#--
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d{ISO8601} - RSLisi [%-5p] %34.34c.%25M - %m%n
#--
log4j.appender.RSLisi-Writer = org.apache.log4j.RollingFileAppender
log4j.appender.RSLisi-Writer.File = /services/RSLisi/rslisi.log
log4j.appender.RSLisi-Writer.MaxFileSize = 100000KB
log4j.appender.RSLisi-Writer.MaxBackupIndex = 100
log4j.appender.RSLisi-Writer.layout = org.apache.log4j.PatternLayout
log4j.appender.RSLisi-Writer.layout.ConversionPattern = %d{ISO8601} - RSLisi [%-5p] %-50c.%30M - %m%n

View File

@ -1,20 +0,0 @@
<launch4jConfig>
<dontWrapJar>true</dontWrapJar>
<headerType>console</headerType>
<jar>hebdobot.jar</jar>
<outfile>target/hebdobot/hebdobot.exe</outfile>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<customProcName>false</customProcName>
<stayAlive>false</stayAlive>
<icon>hebdobot.ico</icon>
<classPath>
<mainClass>org.april.hebdobot.Bot</mainClass>
<cp>lib/*</cp>
</classPath>
<jre>
<minVersion>1.7.0</minVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
</launch4jConfig>

View File

@ -1,9 +0,0 @@
#/bin/sh
mvn clean install
mkdir target/hebdobot
cp target/hebdobot-*.jar target/hebdobot/hebdobot.jar
cp exe/* target/hebdobot
cp LICENSE target/hebdobot
mvn dependency:copy-dependencies -DoutputDirectory=target/hebdobot/lib
launch4j launch4j.xml
(cd target; zip -r9 hebdobot.zip hebdobot)

View File

@ -1,2 +1,28 @@
#!/bin/sh #!/bin/bash
java -cp '*:lib/*' org.april.hebdobot
okCount=0
# Java check.
javaCheck=`which java`
if [[ "$javaCheck" =~ ^/.* ]]; then
echo "Java requirement............... OK"
let "okCount+=1"
else
echo "Java requirement............... MISSING"
fi
# Java version check.
javaVersionCheck=`java -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 8 version requirement..... OK"
let "okCount+=1"
else
echo "Java 8 version requirement..... MISSING"
fi
if [ "$okCount" == 2 ]; then
java -jar hebdobot.jar $@
else
echo "Sorry, Hebdobot launch requires Java 8, abort."
fi

View File

@ -25,7 +25,6 @@ import java.util.Properties;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.april.hebdobot.HebdobotException;
/** /**
* The Class Launcher. * The Class Launcher.
@ -45,9 +44,8 @@ public class HebdobotUtils
* @param source * @param source
* the source * the source
* @return the properties * @return the properties
* @throws HebdobotException
* the hebdobot exception
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static Properties loadProperties(final File source) throws IOException public static Properties loadProperties(final File source) throws IOException
{ {