Mooved Tellstick plugin to plugin folder and added all targets to build xml

This commit is contained in:
Ziver Koc 2017-05-29 17:02:31 +02:00
parent efdbc56859
commit da290e570f
25 changed files with 155 additions and 11 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
/screenlog.0*
/hal.conf
/hal.db*
/build/
build
/lib/Zutil.jar

View file

@ -7,7 +7,10 @@
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/resource" type="java-resource" relativeOutputPath="resource" />
<sourceFolder url="file://$MODULE_DIR$/plugins/zwave/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/tellstick/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/tellstick/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/tellstick/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/zwave/build" />
</content>
<orderEntry type="inheritedJdk" />

6
Jenkinsfile vendored
View file

@ -10,12 +10,12 @@ node {
stage('Build') {
sh 'ant clean'
sh 'ant build'
sh 'ant build-all'
}
stage('Test') {
try {
sh 'ant test'
sh 'ant test-all'
} finally {
step([$class: 'JUnitResultArchiver', testResults: 'build/reports/*.xml'])
}
@ -23,7 +23,7 @@ node {
stage('Package') {
sh 'ant package'
sh 'ant package-all'
archiveArtifacts artifacts: 'build/release/**', fingerprint: true
// Tag artifact

View file

@ -59,6 +59,9 @@
</java>
</target>
<!-- Test targets -->
<target name="test-all" depends="test,test-plugins" />
<target name="test" depends="build-test">
<mkdir dir="${reportsDir}" />
<junit printsummary="yes" haltonfailure="false" fork="true">
@ -72,16 +75,28 @@
</junit>
</target>
<target name="test-plugins" depends="build-test">
<subant target="test" verbose="true">
<fileset dir="plugins/" includes="*/build.xml"/>
</subant>
</target>
<!-- ________________________ BUILD TARGETS ________________________ -->
<!--clean all build paths-->
<!-- clean all build paths -->
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${buildRoot}" includes="**/*"/>
</delete>
<!-- clean plugins -->
<subant target="clean" verbose="true">
<fileset dir="plugins/" includes="*/build.xml"/>
</subant>
</target>
<!--build product code-->
<!-- build product code -->
<target name="build-all" depends="build,build-plugins" />
<target name="build" depends="build-dependencies">
<mkdir dir="${compileDir}" />
<javac srcdir="${srcDir}" destdir="${compileDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
@ -101,6 +116,12 @@
dest="${libDir}" verbose="true" usetimestamp="true"/>
</target>
<target name="build-plugins" depends="build">
<subant target="build" verbose="true">
<fileset dir="plugins/" includes="*/build.xml"/>
</subant>
</target>
<target name="build-test" depends="build">
<mkdir dir="${compileTestDir}" />
<javac srcdir="${testDir}" destdir="${compileTestDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
@ -113,6 +134,9 @@
</copy>
</target>
<!-- generate release packages -->
<target name="package-all" depends="package,package-plugins" />
<target name="package" depends="build">
<copy todir="${releaseDir}" >
<fileset file="${root}/hal.conf.example" />
@ -120,15 +144,32 @@
<fileset file="${root}/logging.properties" />
<fileset file="${root}/run.sh" />
</copy>
<copy todir="${releaseDir}/lib">
<copy todir="${releaseDir}/lib">
<fileset dir="${libDir}" excludes="junit-*.jar,hamcrest-*.jar" />
</copy>
<copy todir="${releaseDir}/resource/web">
<copy todir="${releaseDir}/resource/web">
<fileset dir="resource/web" />
</copy>
<jar destfile="${releaseDir}/${releaseJar}" basedir="${compileDir}" />
</target>
<target name="package-plugins" depends="package">
<subant target="package" verbose="true">
<fileset dir="plugins/" includes="*/build.xml"/>
</subant>
<!-- Copy plugin jars -->
<copy todir="${releaseDir}/plugins" flatten="true" includeEmptyDirs="false">
<fileset dir="plugins/">
<include name="*/build/release/**"/>
</fileset>
</copy>
<!-- Copy plugin libs -->
<copy todir="${releaseDir}/lib" flatten="true" includeEmptyDirs="false">
<fileset dir="plugins/">
<include name="*/lib/**"/>
</fileset>
</copy>
</target>
<!-- ________________________ UTILITY TARGETS ________________________ -->

96
plugins/tellstick/build.xml Executable file
View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Tellstick Plugin" >
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
<!--common properties-->
<property name="root" value="." />
<property name="srcDir" value="${root}/src" />
<property name="testDir" value="${root}/test" />
<property name="libDir" value="${root}/lib" />
<property name="buildRoot" value="${root}/build" />
<property name="compileDir" value="${buildRoot}/production" />
<property name="compileTestDir" value="${buildRoot}/test" />
<property name="releaseDir" value="${buildRoot}/release" />
<property name="releaseJar" value="tellstick.jar" />
<property name="reportsDir" value="../../${buildRoot}/reports" /> <!-- Use Hal reports folder -->
<!-- ________________________ CLASSPATH ________________________ -->
<!--define standard arguments for javac-->
<presetdef name="javac">
<javac includeantruntime="false" />
</presetdef>
<!--classpath included when building-->
<path id="classpath.build">
<fileset dir="${libDir}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${compileDir}" />
<!-- Hal core -->
<pathelement location="../../build/production" />
<fileset dir="../../lib">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="classpath.test">
<pathelement location="${compileTestDir}" />
<pathelement location="../../${compileTestDir}" />
<!--include libraries used for building-->
<path refid="classpath.build"/>
</path>
<!-- ________________________ EXECUTION TARGETS ________________________ -->
<target name="test" depends="build-test">
<mkdir dir="${reportsDir}" />
<junit printsummary="yes" haltonfailure="false" fork="true">
<classpath refid="classpath.test" />
<formatter type="plain" usefile="false" /> <!-- to screen -->
<formatter type="xml" /> <!-- to file -->
<batchtest todir="${reportsDir}" skipNonTests="true">
<fileset dir="${compileTestDir}" includes="**/*Test*.class" />
</batchtest>
</junit>
</target>
<!-- ________________________ BUILD TARGETS ________________________ -->
<!--clean all build paths-->
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${buildRoot}" includes="**/*"/>
</delete>
</target>
<!--build product code-->
<target name="build">
<mkdir dir="${compileDir}" />
<javac srcdir="${srcDir}" destdir="${compileDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
<classpath refid="classpath.build" />
<include name="**/*.java" />
</javac>
<copy todir="${compileDir}">
<fileset dir="${srcDir}"
excludes="**/*.java" />
</copy>
</target>
<target name="build-test" depends="build">
<mkdir dir="${compileTestDir}" />
<javac srcdir="${testDir}" destdir="${compileTestDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
<classpath refid="classpath.test" />
<include name="**/*.java" />
</javac>
</target>
<target name="package" depends="build">
<jar destfile="${releaseDir}/${releaseJar}" basedir="${compileDir}" />
</target>
</project>

View file

@ -34,6 +34,10 @@
</fileset>
</path>
<!-- ________________________ EXECUTION TARGETS ________________________ -->
<target name="test" />
<!-- ________________________ BUILD TARGETS ________________________ -->
<!--clean all build paths-->

View file

@ -6,7 +6,7 @@ import org.junit.Before;
import org.junit.Test;
import se.hal.HalContext;
import se.hal.plugin.tellstick.device.Oregon0x1A2D;
import se.hal.plugin.netscan.NetworkDevice;
import se.hal.util.UTCTimeUtility;
import zutil.db.DBConnection;
import zutil.db.DBUpgradeHandler;
@ -43,7 +43,7 @@ public class SensorDataAggregationDeamonTest {
System.out.println("Adding user to database");
db.exec("INSERT INTO user(id, external, username) VALUES(222, 0, 'test')"); //adding user
System.out.println("Adding sensor to database");
db.exec("INSERT INTO sensor(id, user_id, external_id, type) VALUES(111, 222, 333, '"+Oregon0x1A2D.class.getName()+"')"); //adding sensor
db.exec("INSERT INTO sensor(id, user_id, external_id, type) VALUES(111, 222, 333, '"+NetworkDevice.class.getName()+"')"); //adding sensor
System.out.println("Generating raw data and saving it to the database...");
PreparedStatement stmt = db.getPreparedStatement("INSERT INTO sensor_data_raw (timestamp, sensor_id, data) VALUES(?, ?, ?)");
try{
@ -77,7 +77,7 @@ public class SensorDataAggregationDeamonTest {
//TODO: verify the aggregation
System.out.println("Finnished testing raw data aggregation");
System.out.println("Finished testing raw data aggregation");
}