Skip to content

Commit

Permalink
Bump Java Version to 20 (#902)
Browse files Browse the repository at this point in the history
* 19 -> 20

* change deprecated stuff

* make sonar happy
  • Loading branch information
java-coding-prodigy authored Oct 3, 2023
1 parent 6b9f572 commit 0f3ab26
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/basic-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Basic checks
on: [pull_request]

env:
JAVA_VERSION: 19
JAVA_VERSION: 20

jobs:
spotless:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- cron: '0 20 * * 4'

env:
JAVA_VERSION: 19
JAVA_VERSION: 20

jobs:
sonar:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'master'

env:
JAVA_VERSION: 19
JAVA_VERSION: 20

jobs:
docker:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Docker Verify
on: [pull_request]

env:
JAVA_VERSION: 19
JAVA_VERSION: 20

jobs:
docker:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defaults:
shell: bash

env:
JAVA_VERSION: 19
JAVA_VERSION: 20

jobs:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TJ-Bot

[![codefactor](https://img.shields.io/codefactor/grade/github/together-java/tj-bot)](https://www.codefactor.io/repository/github/together-java/tj-bot)
![Java](https://img.shields.io/badge/Java-19-ff696c)
![Java](https://img.shields.io/badge/Java-20-ff696c)
[![license](https://img.shields.io/github/license/Together-Java/TJ-Bot)](https://github.com/Together-Java/TJ-Bot/blob/master/LICENSE)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/Together-Java/TJ-Bot?label=release)

Expand Down
2 changes: 1 addition & 1 deletion application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repositories {
var outputImage = 'togetherjava.org:5001/togetherjava/tjbot:' + System.getenv('BRANCH_NAME') ?: 'latest'

jib {
from.image = 'eclipse-temurin:19'
from.image = 'eclipse-temurin:20'
to {
image = outputImage
auth {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.*;
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Error;

import java.awt.Color;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.HttpURLConnection;
import java.net.URISyntaxException;
import java.net.http.HttpResponse;
import java.util.*;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -169,7 +170,7 @@ private HandlerResponse handleSuccessfulResponse(QueryResult queryResult) {
for (SubPod subPod : pod.getSubPods()) {
try {
images.add(WolframAlphaImages.renderSubPod(subPod));
} catch (UncheckedIOException e) {
} catch (IOException | URISyntaxException e) {
LOGGER.error(
"Failed to render sub pod (title: '{}') from pod (title: '{}') from the WolframAlpha response (for query: '{}')",
subPod.getTitle(), pod.getTitle(), query, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

import javax.imageio.ImageIO;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
Expand All @@ -16,7 +14,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -55,7 +54,7 @@ static BufferedImage renderTitle(String title) {
return image;
}

static BufferedImage renderSubPod(SubPod subPod) {
static BufferedImage renderSubPod(SubPod subPod) throws IOException, URISyntaxException {
WolframAlphaImage sourceImage = subPod.getImage();

int widthPx = sourceImage.getWidth() + 2 * IMAGE_MARGIN_PX;
Expand All @@ -65,12 +64,9 @@ static BufferedImage renderSubPod(SubPod subPod) {
new BufferedImage(widthPx, heightPx, BufferedImage.TYPE_4BYTE_ABGR);
Graphics graphics = destinationImage.getGraphics();

try {
graphics.drawImage(ImageIO.read(new URL(sourceImage.getSource())), IMAGE_MARGIN_PX,
IMAGE_MARGIN_PX, null);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
graphics.drawImage(ImageIO.read(new URI(sourceImage.getSource()).toURL()), IMAGE_MARGIN_PX,
IMAGE_MARGIN_PX, null);


return destinationImage;
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ subprojects {
options.encoding = 'UTF-8'

// Nails the Java-Version of every Subproject
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
sourceCompatibility = JavaVersion.VERSION_20
targetCompatibility = JavaVersion.VERSION_20
}

compileJava(compileTasks)
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 10 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,10 +131,13 @@ 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.
if ! command -v java >/dev/null 2>&1
then
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
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi


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

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down

0 comments on commit 0f3ab26

Please sign in to comment.