FIRST-Tech-Challenge / FIRST-Tech-Challenge/FtcRobotController

Consider supporting cross-compilation from newer JDKs without warnings

Open
#12 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.3k
Forks
9.9k
Avg merge
18m
Merged PRs (30d)
1

Description

Attempt to compile using JDK 13 or higher complains with:

> warning: [options] source value 7 is obsolete and will be removed in a future release
> warning: [options] target value 7 is obsolete and will be removed in a future release
> warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.

And to make matters even more annoying, it happens for 4-tasks, so you get 12 total warnings every time you build.

Installing an ancient Java 7 JDK is one option, or not using anything newer than a Java 11 JDK for cross-compilation is another, but many systems are switching to installing JDK 13 as the default, and the below code snippet allows newer cross-compilation JDKs without emitting the annoying warnings, yet keeps everything else functionally equivalent:

### build.gradle (top-level one, in the allprojects {} section)
```groovy
// Avoid warning message from newer JDKs about Java 7 source/target being obsolete
tasks.withType(JavaCompile).whenTaskAdded { JavaCompile javaCompile ->
javaCompile.options.compilerArgs << '-Xlint:-options'
}
```

The snippet directly replaced in the build.gradle file can be seen here:
https://github.com/FIRST-Tech-Challenge/FtcRobotController/pull/11/files

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.