Migrated to jdb-build-1.9, documentation.

This commit is contained in:
Jonathan Bernard committed 2012-08-30 06:33:35 -07:00
1 parent d076b739f5
commit 10677e5705
31 files changed
+128 -102

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
<project name="Time Analyzer" default="compile"> <project name="Time Analyzer" default="compile">
<property file="project.properties"/> <property file="project.properties"/>
<import file="jdb-build-1.5.xml"/> <import file="jdb-build-1.9.xml"/>
<target name="init"/> <target name="init"/>
+66 -17
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project name="Jonathan Bernard Build Common"> <project name="Jonathan Bernard Build Common"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property environment="env"/> <property environment="env"/>
@@ -16,7 +17,7 @@
<property name="build.dir" value="${basedir}/build"/> <property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/> <property name="lib.dir" value="${basedir}/lib"/>
<property name="resources.dir" value="${basedir}/resources"/> <property name="resources.dir" value="${basedir}/resources"/>
<property name="lib.local" value="true"/> <property name="splash.image" value="splash.png"/>
<!--======== PATHS ========--> <!--======== PATHS ========-->
<path id="groovy.classpath"> <path id="groovy.classpath">
@@ -32,13 +33,13 @@
</path> </path>
<path id="compile-libs"> <path id="compile-libs">
<fileset dir="${build.dir}/lib/compile"> <fileset dir="${build.dir}/lib/compile/jar">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</path> </path>
<path id="runtime-libs"> <path id="runtime-libs">
<fileset dir="${build.dir}/lib/runtime"> <fileset dir="${build.dir}/lib/runtime/jar">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</path> </path>
@@ -53,25 +54,43 @@
classname="org.codehaus.groovy.ant.Groovy"/> classname="org.codehaus.groovy.ant.Groovy"/>
</target> </target>
<target name="init"/>
<target name="clean" depends="-init"> <target name="clean" depends="-init">
<delete dir="${build.dir}"/> <delete dir="${build.dir}"/>
</target> </target>
<!--======== LIBRARY TARGETS ========--> <!--======== LIBRARY TARGETS ========-->
<target name="lib" depends="-lib-local,-lib-ivy"/> <target name="-lib" depends="-lib-local,-lib-ivy,lib"/>
<target name="-lib-ivy" unless="${lib.local}"/> <target name="lib"/>
<target name="-init-ivy">
<ivy:settings id="ivy.settings" file="ivysettings.xml"/>
</target>
<target name="-lib-ivy" depends="-init-ivy" unless="${lib.local}">
<ivy:retrieve settingsRef="ivy.settings"
pattern="${lib.dir}/[conf]/[type]/[artifact]-[revision].[ext]"
conf="compile,runtime"/>
</target>
<target name="-lib-groovy" if="${lib.local}">
<copy todir="${build.dir}/lib/runtime/jar">
<fileset dir="${env.GROOVY_HOME}/embeddable"/>
</copy>
</target>
<target name="-lib-local" if="${lib.local}"> <target name="-lib-local" if="${lib.local}">
<echo message="Resolving libraries locally."/> <echo message="Resolving libraries locally."/>
<mkdir dir="${build.dir}/lib/compile"/> <mkdir dir="${build.dir}/lib/compile/jar"/>
<mkdir dir="${build.dir}/lib/runtime"/> <mkdir dir="${build.dir}/lib/runtime/jar"/>
<copy todir="${build.dir}/lib/compile" failonerror="false"> <copy todir="${build.dir}/lib/compile/jar" failonerror="false">
<fileset dir="${lib.dir}/compile"/> <fileset dir="${lib.dir}/compile/jar"/>
</copy> </copy>
<copy todir="${build.dir}/lib/runtime" failonerror="false"> <copy todir="${build.dir}/lib/runtime/jar" failonerror="false">
<fileset dir="${lib.dir}/runtime"/> <fileset dir="${lib.dir}/runtime/jar"/>
</copy> </copy>
</target> </target>
@@ -90,14 +109,15 @@
<propertyfile file="${versioning.file}"> <propertyfile file="${versioning.file}">
<entry key="version" value="${new-version}" operation="=" <entry key="version" value="${new-version}" operation="="
type="string"/> type="string"/>
<entry key="build.number" value="0" type="int" operation="="/>
</propertyfile> </propertyfile>
</target> </target>
<!--======== COMPILATION TARGETS ========--> <!--======== COMPILATION TARGETS ========-->
<target name="-compile-groovy" depends="-init,-init-groovy,lib"> <target name="-compile-groovy" depends="-init,-init-groovy,-lib,-lib-groovy">
<mkdir dir="${build.dir}/main/classes"/> <mkdir dir="${build.dir}/main/classes"/>
<groovyc srcdir="${src.dir}/main" destdir="${build.dir}/main/classes" <groovyc srcdir="${src.dir}/main" destdir="${build.dir}/main/classes"
includeAntRuntime="false"> fork="true" includeAntRuntime="false">
<classpath> <classpath>
<path refid="groovy.classpath"/> <path refid="groovy.classpath"/>
@@ -107,7 +127,7 @@
</groovyc> </groovyc>
</target> </target>
<target name="-compile-java" depends="-init,lib"> <target name="-compile-java" depends="-init,-lib">
<mkdir dir="${build.dir}/main/classes"/> <mkdir dir="${build.dir}/main/classes"/>
<javac srcdir="${src.dir}/main" destdir="${build.dir}/main/classes" <javac srcdir="${src.dir}/main" destdir="${build.dir}/main/classes"
includeAntRuntime="false" classpathref="compile-libs"/> includeAntRuntime="false" classpathref="compile-libs"/>
@@ -176,18 +196,47 @@
</target> </target>
<!--======== BUILD TARGETS ========--> <!--======== BUILD TARGETS ========-->
<target name="-build-modular" <target name="-build-modular-lib" unless="executable.jar"
depends="compile,increment-build-number,resources"> depends="compile,increment-build-number,resources">
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar" <jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"
basedir="${build.dir}/main/classes"/> basedir="${build.dir}/main/classes"/>
</target> </target>
<target name="-build-modular-executable" if="executable.jar"
depends="compile,increment-build-number,resources">
<pathconvert property="jar.classpath" pathsep=" " refid="runtime-libs">
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
</pathconvert>
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"
basedir="${build.dir}/main/classes">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
<attribute name="SplashScreen-Image" value="${splash.image}"/>
</manifest>
</jar>
</target>
<target name="-build-modular"
depends="-build-modular-lib,-build-modular-executable"/>
<target name="-build-packed-libs" <target name="-build-packed-libs"
depends="compile,increment-build-number,resources"> depends="compile,increment-build-number,resources">
<unjar destdir="${build.dir}/main/classes"> <unjar destdir="${build.dir}/main/classes">
<fileset dir="${build.dir}/lib/runtime"/> <fileset dir="${build.dir}/lib/runtime/jar"/>
</unjar> </unjar>
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar" <jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3 -2
View File
@@ -1,4 +1,5 @@
#Sat, 22 Jan 2011 19:30:42 -0600 #Wed, 29 Aug 2012 15:10:32 -0700
name=time-analyzer name=time-analyzer
version=0.1 version=0.1
build.number=4 build.number=5
lib.local=true
Binary file not shown.
+46
View File
@@ -0,0 +1,46 @@
import com.jdbernard.timeanalyzer.processors.*
import com.jdbernard.timeanalyzer.categories.*
import com.jdbernard.timeanalyzer.categorizationplans.*
import com.jdbernard.timeanalyzer.chart.*
import com.jdbernard.timeanalyzer.events.*
import com.jdbernard.timestamper.core.*
import com.quantumdigital.ithelp.timeanalyzer.*
import org.joda.time.*
import org.joda.time.format.*
import org.jfree.chart.*
import org.jfree.data.general.*
import org.jfree.util.SortOrder
tep = new TimelineEventProcessor()
tep.exclusions << ~/.*Home.*/
pf = PeriodFormat.getDefault()
topcat = new FilteredCategory("Top Category")
twoLevelCatPlan = new TwoLevelCategorizationPlan()
descriptionBasedCatPlan = new DescriptionBasedCategorizationPlan()
topcat.categorizationPlans << twoLevelCatPlan
topcat.categorizationPlans << descriptionBasedCatPlan
loadEvents = { file, processor ->
fileSource = new FileTimelineSource(file.toURI())
timeline = fileSource.read()
return processor.process(timeline) }
makePieDataset = { category ->
DefaultPieDataset dpds = new DefaultPieDataset()
category.categories.each { cat ->
dpds.setValue(cat.description, cat.duration.standardSeconds) }
category.events.each { entry ->
dpds.setValue(entry.description, entry.duration.standardSeconds) }
dpds.sortByValues(SortOrder.DESCENDING)
return dpds }
makeFrame = { categoryName, dataset ->
return new ChartFrame(categoryName,
ChartFactory.createPieChart("Time Spent", dataset, true, true, false)) }
createDailyCategory = { file, processor ->
events = loadEvents(file)
Binary file not shown.
@@ -47,11 +47,9 @@ public abstract class Category implements Comparable<Category> {
* made and the `Event` matches.*/ * made and the `Event` matches.*/
public Event addEvent(Event event) { public Event addEvent(Event event) {
// see if we have or can create a subcategory that will hold this event // Try first to add it to a subcategory (or create a new subcategory).
Event addedEvent = addToSubcategory(event) if (!addToSubcategory(event)) {
// Cannot add to a subcategory, add to ourselves.
// no, let's just add it on ourself
if (!addedEvent) {
events << event events << event
addedEvent = event } addedEvent = event }
@@ -4,13 +4,9 @@ import com.jdbernard.timeanalyzer.events.Event
public class GeneralCategory extends Category { public class GeneralCategory extends Category {
public GeneralCategory() { public GeneralCategory() { this("General") }
this("General")
}
public GeneralCategory(String description) { public GeneralCategory(String description) { super(description) }
super(description)
}
public boolean matchesEvent(Event e) { true } public boolean matchesEvent(Event e) { true }
@@ -11,15 +11,12 @@ public class TimeIntervalCategoryFilter implements CategoryFilter {
ReadableInterval interval ReadableInterval interval
public TimeIntervalCategoryFilter(ReadableInterval interval) { public TimeIntervalCategoryFilter(ReadableInterval interval) {
this.interval = interval this.interval = interval }
}
public TimeIntervalCategoryFilter(ReadableInstant start, public TimeIntervalCategoryFilter(ReadableInstant start,
ReadableInstant end) { ReadableInstant end) {
this.interval = new Interval(start, end) this.interval = new Interval(start, end) }
}
public boolean matchesEvent(Event event) { public boolean matchesEvent(Event event) {
return interval.contains(event.start) return interval.contains(event.start) }
}
} }
@@ -13,9 +13,7 @@ public class TimelineEventProcessor {
public TimelineEventProcessor() {} public TimelineEventProcessor() {}
public TimelineEventProcessor(List exclusions) { public TimelineEventProcessor(List exclusions) { this.exclusions = exclusions }
this.exclusions = exclusions
}
public List<Event> process(Timeline timeline) { public List<Event> process(Timeline timeline) {
List<Event> events = [] List<Event> events = []
@@ -31,15 +29,12 @@ public class TimelineEventProcessor {
// duration of the previous event // duration of the previous event
if (events.size > 0) { if (events.size > 0) {
Event lastEvent = events[-1] Event lastEvent = events[-1]
lastEvent.duration = new Duration(lastEvent.start, e.start) lastEvent.duration = new Duration(lastEvent.start, e.start) }
}
events << e events << e }
}
def excluded = events.findAll { event -> def excluded = events.findAll { event ->
exclusions.any { exclusion -> event.description ==~ exclusion } exclusions.any { exclusion -> event.description ==~ exclusion } }
}
return events - excluded return events - excluded
} }
-56
View File
@@ -1,56 +0,0 @@
import com.jdbernard.timeanalyzer.*
import com.jdbernard.timestamper.core.*
import com.quantumdigital.ithelp.timeanalyzer.*
import org.joda.time.*
import org.joda.time.format.*
import org.jfree.chart.*
import org.jfree.data.general.*
import org.jfree.util.SortOrder
tep = new TimelineEventProcessor()
tep.exclusions << ~/Going Home/
pf = PeriodFormat.getDefault()
fileSource = new FileTimelineSource(new File("timeline.jdbernard.txt").toURI())
timeline = fileSource.read()
events = tep.process(timeline)
topcat = new FilteredCategory("Top Category")
topcat.filters << new TimeIntervalCategoryFilter(
new DateTime(2011, 1, 24, 0, 0, 0, 0), new DateTime(2011, 1, 25, 0, 0, 0, 0))
twoLevelCatPlan = new TwoLevelCategorizationPlan()
descriptionBasedCatPlan = new DescriptionBasedCategorizationPlan()
topcat.categorizationPlans << twoLevelCatPlan
topcat.categorizationPlans << descriptionBasedCatPlan
ithelpcat = new TwoLevelCategory("ITHelp")
ticketCatPlan = new TicketCategorizationPlan()
ithelpcat.categorizationPlans << ticketCatPlan
ithelpcat.categorizationPlans << descriptionBasedCatPlan
topcat.categories << ithelpcat
events.each { if (topcat.matchesEvent(it)) topcat.addEvent(it) }
makePieDataset = { category ->
DefaultPieDataset dpds = new DefaultPieDataset()
category.categories.each { cat ->
dpds.setValue(cat.description, cat.duration.standardSeconds) }
category.events.each { entry ->
dpds.setValue(entry.description, entry.duration.standardSeconds) }
dpds.sortByValues(SortOrder.DESCENDING)
return dpds
}
topcatDataset = makePieDataset(topcat)
ithelpDataset = makePieDataset(ithelpcat)
topcatFrame = new ChartFrame("Top Category",
ChartFactory.createPieChart("Time Spent", topcatDataset, true, true, false))
ithelpFrame = new ChartFrame("ITHelp",
ChartFactory.createPieChart("Time Spent", ithelpDataset, true, true, false))