diff --git a/CircuitSim1.8.0.jar b/CircuitSim1.8.2-austin.jar similarity index 56% rename from CircuitSim1.8.0.jar rename to CircuitSim1.8.2-austin.jar index 0e74297..24c78c9 100644 Binary files a/CircuitSim1.8.0.jar and b/CircuitSim1.8.2-austin.jar differ diff --git a/README.md b/README.md index 049f442..b0d3e8a 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,10 @@ To make your own CircuitSim autograder: and writing a new `README.md` 2. Edit the project name in `gradle.properties` 3. Write some tests in `src/main/java/edu/gatech/cs2110/circuitsim/tests/` - 4. Test with `./gradlew run` and generate `build/libs/hwX-tester.jar` - with `./gradlew jar` + 4. Generate `build/image/bin/hwX-tester`, a shell script, with + `./gradlew jlink` + 5. Distribute to students the zipped up archive `build/hwX-tester.zip`, + generated by `./gradlew jlinkZip` ### Writing Tests diff --git a/build.gradle b/build.gradle index 77c8d9b..40ab994 100644 --- a/build.gradle +++ b/build.gradle @@ -1,60 +1,54 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java project to get you started. - * For more details take a look at the Java Quickstart chapter in the Gradle - * user guide available at https://docs.gradle.org/4.7/userguide/tutorial_java_projects.html - */ +// Based on: +// https://github.com/beryx-gist/badass-jlink-example-log4j2-javafx +// +// The jlink task will produce build/image/bin/hwX-tester (a shell script) +// The jlinkZip task will produce build/hwX-tester.zip +// +// More info: https://badass-jlink-plugin.beryx.org/releases/latest/ plugins { - // Apply the java plugin to add support for Java - id 'java' - - // Apply the application plugin to add support for building an application + id 'java-library' id 'application' + id 'org.openjfx.javafxplugin' version '0.0.8' + id 'org.beryx.jlink' version '2.17.0' } -// Build for Java 8 -sourceCompatibility = '1.8' -targetCompatibility = '1.8' +repositories { + mavenCentral() -// Define the main class for the application -mainClassName = 'edu.gatech.cs2110.circuitsim.launcher.TesterLauncher' + flatDir { + dirs '.' + } +} dependencies { - // Don't need to put gson in here since the CircuitSim jar already - // includes it - compile ':CircuitSim1.8.0:' - compile 'org.junit.jupiter:junit-jupiter-api:5.2.0' - compile 'org.junit.jupiter:junit-jupiter-params:5.2.0' - compile 'org.junit.jupiter:junit-jupiter-engine:5.2.0' - compile 'org.junit.platform:junit-platform-launcher:1.2.0' + implementation 'com.google.code.gson:gson:2.8.6' + implementation ':CircuitSim1.8.2-austin:' + implementation 'org.junit.jupiter:junit-jupiter-api:5.5.2' + implementation 'org.junit.jupiter:junit-jupiter-params:5.5.2' + implementation 'org.junit.jupiter:junit-jupiter-engine:5.5.2' + implementation 'org.junit.platform:junit-platform-launcher:1.5.2' +} + +javafx { + version = '13' + modules = ['javafx.controls'] } compileJava { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } -// In this section you declare where to find the dependencies of your project -repositories { - // Use jcenter for resolving your dependencies. - // You can declare any Maven/Ivy/file repository here. - jcenter() +mainClassName = 'tester/edu.gatech.cs2110.circuitsim.launcher.TesterLauncher' - flatDir { - dirs '.' +jlink { + options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'] + imageZip = file("$buildDir/hwX-tester.zip") + launcher { + name = 'hwX-tester' } } -jar { - manifest { - attributes('Main-Class': mainClassName) - } - - // Include dependencies - from { configurations.testRuntime.collect { it.isDirectory() ? it : zipTree(it) } } -} - javadoc { title 'CircuitSim Autograder API' include 'edu/gatech/cs2110/circuitsim/api/*', 'edu/gatech/cs2110/circuitsim/extension/*' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 91ca28c..cc4fdc2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 16d2805..9492014 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index cccdd3d..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ 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="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ 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 +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $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" ;; + 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 @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +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" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d..24467a1 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java b/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java index cb806ef..97f7b55 100644 --- a/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java +++ b/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java @@ -2,11 +2,9 @@ import static org.junit.platform.engine.TestExecutionResult.Status.SUCCESSFUL; import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; -import static org.junit.platform.engine.discovery.DiscoverySelectors.selectPackage; +import static org.junit.platform.engine.discovery.DiscoverySelectors.selectModule; -import java.io.FileNotFoundException; import java.io.PrintStream; -import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -16,6 +14,7 @@ import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; public class TesterLauncher { + private static final String TEST_MODULE = "tester"; private static final String TEST_PACKAGE = "edu.gatech.cs2110.circuitsim.tests"; private static final int MAX_FAILURES = 8; private String pkg; @@ -147,7 +146,7 @@ private LauncherDiscoveryRequest buildDiscoveryRequest(String testClassName) { LauncherDiscoveryRequestBuilder builder = new LauncherDiscoveryRequestBuilder(); if (testClassName == null) { - builder.selectors(selectPackage(pkg)); + builder.selectors(selectModule(TEST_MODULE)); } else { String fullyQualifiedClassName = String.format("%s.%s", pkg, testClassName); builder.selectors(selectClass(fullyQualifiedClassName)); diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..4d0cc6e --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,13 @@ +module tester { + requires javafx.controls; + requires com.google.gson; + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; + requires org.junit.jupiter.engine; + requires org.junit.platform.launcher; + requires circuitsim; + + exports edu.gatech.cs2110.circuitsim.extension; + exports edu.gatech.cs2110.circuitsim.launcher; + exports edu.gatech.cs2110.circuitsim.tests; +}