Skip to content

Commit

Permalink
Attempt adding Java 11+ support with modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ausbin committed Jan 19, 2020
1 parent cc2ba18 commit 2eb6e61
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 67 deletions.
Binary file renamed CircuitSim1.8.0.jar → CircuitSim1.8.2-austin.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
72 changes: 33 additions & 39 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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/*'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
51 changes: 31 additions & 20 deletions gradlew
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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

Expand All @@ -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" "$@"
18 changes: 17 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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.launcher;
}

0 comments on commit 2eb6e61

Please sign in to comment.