Skip to content

Commit

Permalink
Compile tests using Java 10
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jul 8, 2018
1 parent 5331ef8 commit f4dcd1e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
14 changes: 8 additions & 6 deletions build.gradle
Expand Up @@ -121,10 +121,16 @@ allprojects { subproj ->

subproj.afterEvaluate { evaluatedProject ->
evaluatedProject.tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
evaluatedProject.tasks.getByName('compileJava') {
sourceCompatibility = javacRelease
targetCompatibility = javacRelease // needed by asm
options.compilerArgs += ['--release', javacRelease]
options.encoding = 'UTF-8'
}
evaluatedProject.tasks.getByName('compileTestJava') {
sourceCompatibility = 10
targetCompatibility = 10
}
}

Expand Down Expand Up @@ -153,6 +159,7 @@ allprojects { subproj ->

// See: https://docs.oracle.com/javase/9/tools/javac.htm#JSWOR627
compileTestJava.options.compilerArgs += [
'-parameters',
'-Xlint:cast',
'-Xlint:classfile',
'-Xlint:deprecation',
Expand All @@ -173,11 +180,6 @@ allprojects { subproj ->
'-Xlint:-overrides'
]

compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs += '-parameters'
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = '1.8'
Expand Down
2 changes: 1 addition & 1 deletion documentation/src/test/java/example/DynamicTestsDemo.java
Expand Up @@ -116,7 +116,7 @@ Stream<DynamicTest> generateRandomNumberOfTests() {

// Generates random positive integers between 0 and 100 until
// a number evenly divisible by 7 is encountered.
Iterator<Integer> inputGenerator = new Iterator<Integer>() {
Iterator<Integer> inputGenerator = new Iterator<>() {

Random random = new Random();
// end::user_guide[]
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -14,7 +14,7 @@ vintageBaseline = 5.2.0

# --release release
# Compiles against the public, supported and documented API for a specific VM version.
# Supported release targets are 6, 7, 8, and 9.
# Supported release targets are 6, 7, 8, 9, 10, and 11.
# Note that if --release is added then -target and -source are ignored.
javacRelease = 8

Expand Down
Expand Up @@ -139,7 +139,7 @@ void toStreamWithLongStream() {
@SuppressWarnings({ "unchecked", "serial" })
void toStreamWithCollection() {
AtomicBoolean collectionStreamClosed = new AtomicBoolean(false);
Collection<String> input = new ArrayList<String>() {
Collection<String> input = new ArrayList<>() {

{
add("foo");
Expand All @@ -164,7 +164,7 @@ public Stream<String> stream() {
@SuppressWarnings("unchecked")
void toStreamWithIterable() {

Iterable<String> input = new Iterable<String>() {
Iterable<String> input = new Iterable<>() {

@Override
public Iterator<String> iterator() {
Expand Down
Expand Up @@ -41,7 +41,7 @@ void withNullClass() {

@Test
void appendWithIllegalName() {
ToStringBuilder builder = new ToStringBuilder("");
var builder = new ToStringBuilder("");

assertThrows(PreconditionViolationException.class, () -> builder.append(null, ""));
assertThrows(PreconditionViolationException.class, () -> builder.append("", ""));
Expand Down Expand Up @@ -129,7 +129,7 @@ void withPrimitiveDoubleArrayField() {
@SuppressWarnings("serial")
void withMapField() {
// @formatter:off
Map<String,Object> map = new LinkedHashMap<String,Object>() {{
Map<String,Object> map = new LinkedHashMap<>() {{
put("foo", 42);
put("bar", "enigma");
}};
Expand All @@ -140,7 +140,7 @@ void withMapField() {

@Test
void withDemoImplementation() {
RoleModel roleModel = new RoleModel("Dilbert", 42);
var roleModel = new RoleModel("Dilbert", 42);
assertEquals("RoleModel [name = 'Dilbert', age = 42]", roleModel.toString());
}

Expand All @@ -153,7 +153,6 @@ static class RoleModel {
}

RoleModel(String name, int age) {
super();
this.name = name;
this.age = age;
}
Expand Down

0 comments on commit f4dcd1e

Please sign in to comment.