Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle migration #272

Merged
merged 13 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,14 @@ Copyright (c) 2018 Bright Spots

## Dependencies

#### Java Runtime Environment (JRE) 10+

[Main website](http://www.oracle.com/technetwork/java/javase/downloads/index.html)

#### Apache POI Java API for Microsoft Documents 3.16
[Main website](https://poi.apache.org/index.html)

[Binaries](https://archive.apache.org/dist/poi/release/bin/poi-bin-3.16-20170419.tar.gz)

#### Jackson databind General data-binding package:
[Binaries](http://central.maven.org/maven2/com/fasterxml/jackson/core/)

Jackson Annotations 2.9.6

Jackson Core 2.9.6

Jackson Databind 2.9.6
#### Java JDK 11+
[Main website](https://jdk.java.net/)

#### Other Dependencies
See the `dependencies` entry in the [Gradle build file](build.gradle). Gradle should be used to acquire these libraries automatically.

## Configuration
Config file documentation is available [here](src/main/resources/config_file_documentation.txt).
Config file documentation is available [here](src/main/resources/com/rcv/config_file_documentation.txt).

## User Guide
User Guide is available [here](UserGuide.txt).
22 changes: 11 additions & 11 deletions UserGuide.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Universal Tabulator User Guide
# Universal Tabulator User Guide

Overview:
## Overview:

The Universal Tabulator is a free open source application designed to quickly and accurately tabulate ranked choice voting elections using a variety of rules commonly in use in North America.

Expand All @@ -19,14 +19,16 @@ The Tabulator provides an interface for:
- Validating contest configuration files to ensure they are well-formed, and all values are within expected ranges
- Tabulating a contest with a contest configuration file

Launching the Tabulator:
## Launching the Tabulator:

Once you've downloaded or built the binary, double-click rcv.jar file to launch the GUI version of the Tabulator.
You may need to install Java SE Runtime Environment 10 first: http://www.oracle.com/technetwork/java/javase/downloads/jre10-downloads-4417026.html
Note that the Tabulator does not currently run in a Linux environment (see issue #168) or with Java 11 (#239). It should run properly on a Mac or Windows machine running Java 10.
You can also run the Tabulator from the command line by supplying an existing config file as the only runtime argument.
You must have Java JDK 11 or higher installed on your system: https://jdk.java.net/
Once you've built the binary using Gradle or downloaded a pre-built version, run the bin/rcv script if using MacOS or Linux, or bin/rcv.bat if using Windows to launch the GUI version of the Tabulator.
You can also run the Tabulator from the command line by including the flag "-cli" and then supplying a path to an existing config file, e.g.:
$ rcv -cli path/to/config
Finally, you can activate a special "convert-to-cdf" function via the command line to export the CVR as a CDF JSON instead of tabulating the results, e.g.:
$ rcv -cli path/to/config convert-to-cdf

Loading and Tabulating a Contest:
## Loading and Tabulating a Contest:

The Tabulator includes several example contest configuration files and associated cast vote record files.
Click "Load..." at the top of the window and browse into the "test_data" folder under src/test/resources.
Expand All @@ -35,13 +37,11 @@ Click on the configuration tabs (Output, CVR Files, Candidates, Rules) to see ho
Click "Validate" to check if this configuration is valid. You will see the results in the black console area at the bottom of the main window.
Click "Tabulate" to tabulate the election. You will see the results in the console, including the location and names of output files.

Viewing Tabulator outputs:
## Viewing Tabulator outputs:

Tabulator output file names automatically include the current date and time, e.g. 2018-09-09_15-34-00_summary.xlsx. This keeps them separate if you tabulate the same contest multiple times.
Look in the console window to see where the output spreadsheet was written, e.g.
2018-09-09 18:55:53 PDT INFO: Generating summary spreadsheet: /Users/Me/Documents/rcv/test_output/2018_maine_gov_primary_dem/2018-09-09_18-55-33_summary.xlsx
Double-click on the summary spreadsheet to open it. You may have to install OpenOffice (or some other Excel file reader) first:
https://www.openoffice.org/download/
Find the audit log file and double-click on it to open it. It is a standard text file and can be displayed with any kind of text editor.


66 changes: 66 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
plugins {
id 'application'
id 'idea'
id 'java'
id 'org.openjfx.javafxplugin' version '0.0.7'
id 'org.beryx.jlink' version '2.10.4'
}

repositories {
mavenCentral()
}

dependencies {
compile 'org.apache.commons:commons-csv:1.6'
compile 'org.apache.poi:poi-ooxml:4.1.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.9.9'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.9'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
testCompile 'org.junit.jupiter:junit-jupiter-api:5.5.0-M1'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0-M1'
}

// ### Application plugin settings
application {
mainClassName = "$moduleName/com.rcv.Main"
}

// ### Idea plugin settings
idea {
module {
outputDir = file("out/production/classes")
}
}

// ### Java plugin settings
sourceCompatibility = JavaVersion.VERSION_11

compileJava {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

test {
useJUnitPlatform()
testLogging {
events 'PASSED', 'FAILED', 'SKIPPED'
}
}

// ### JavaFX plugin settings
javafx {
version = "12.0.1"
modules = ['javafx.controls', 'javafx.fxml']
}

// ### jlink plugin settings
jlink {

mergedModule {
requires "java.xml"
}

options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'rcv'
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
172 changes: 172 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
echo "$*"
}

die () {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
Loading