Skip to content

Commit 1d722be

Browse files
committed
Update to Java 21
1 parent f462dfb commit 1d722be

File tree

6 files changed

+80
-85
lines changed

6 files changed

+80
-85
lines changed

autobot/build.gradle.kts

+31-24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.github.spotbugs.snom.Confidence
2+
import com.github.spotbugs.snom.Effort
13
import com.google.common.io.Files as GoogleFiles
24
import com.google.googlejavaformat.java.Formatter
35
import com.google.googlejavaformat.java.JavaFormatterOptions
@@ -15,7 +17,7 @@ import okhttp3.Request
1517
import okhttp3.RequestBody.Companion.toRequestBody
1618
import org.yaml.snakeyaml.Yaml
1719

18-
val javaVersion = JavaVersion.VERSION_17
20+
val javaVersion = JavaVersion.VERSION_21
1921

2022
fun String.runCommand(currentWorkingDir: File = file("./")): String {
2123
val byteOut = ByteArrayOutputStream()
@@ -45,11 +47,11 @@ plugins {
4547
alias(libs.plugins.spring.boot)
4648
alias(libs.plugins.gradle.git.properties)
4749
id("checkstyle")
48-
id("pmd")
50+
// id("pmd")
4951
alias(libs.plugins.spotbugs.gradle)
5052
id("jacoco")
5153
alias(libs.plugins.versions.gradle)
52-
alias(libs.plugins.ca.cutterslade.analyze)
54+
// alias(libs.plugins.ca.cutterslade.analyze)
5355
alias(libs.plugins.docker.gradle)
5456
}
5557

@@ -74,6 +76,12 @@ val intTestImplementation: Configuration by configurations.getting {
7476

7577
configurations["intTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())
7678

79+
configurations.checkstyle {
80+
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
81+
select("com.google.guava:guava:0")
82+
}
83+
}
84+
7785
// Static Analysis Plugin Configuration
7886

7987
checkstyle {
@@ -85,18 +93,18 @@ jacoco {
8593
toolVersion = libs.versions.jacoco.get()
8694
}
8795

88-
pmd {
89-
isConsoleOutput = true
90-
isIgnoreFailures = false
91-
ruleSets = listOf()
92-
ruleSetFiles = files("config/pmd/pmd.xml")
93-
toolVersion = libs.versions.pmd.get()
94-
}
96+
//pmd {
97+
// isConsoleOutput = true
98+
// isIgnoreFailures = false
99+
// ruleSets = listOf()
100+
// ruleSetFiles = files("config/pmd/pmd.xml")
101+
// toolVersion = libs.versions.pmd.get()
102+
//}
95103

96104
spotbugs {
97105
ignoreFailures.set(false)
98-
setEffort("max")
99-
setReportLevel("low")
106+
effort.set(Effort.MAX)
107+
reportLevel.set(Confidence.LOW)
100108
showProgress.set(false)
101109
toolVersion.set(libs.versions.spotbugs.get())
102110
}
@@ -149,12 +157,12 @@ dependencies {
149157
"org.springframework.boot:spring-boot-properties-migrator"
150158
).forEach { runtimeOnly(it) }
151159

152-
listOf(
153-
"org.springframework.boot:spring-boot-starter-actuator",
154-
"org.springframework.boot:spring-boot-starter-security",
155-
"org.springframework.boot:spring-boot-starter-thymeleaf",
156-
"org.springframework.boot:spring-boot-starter-web"
157-
).forEach { permitUnusedDeclared(it) }
160+
// listOf(
161+
// "org.springframework.boot:spring-boot-starter-actuator",
162+
// "org.springframework.boot:spring-boot-starter-security",
163+
// "org.springframework.boot:spring-boot-starter-thymeleaf",
164+
// "org.springframework.boot:spring-boot-starter-web"
165+
// ).forEach { permitUnusedDeclared(it) }
158166

159167
listOf(
160168
libs.junit.bom
@@ -392,8 +400,7 @@ tasks.register("validateYaml") {
392400
doLast {
393401
val input = File(project.projectDir, "src/main/resources/application.yml")
394402
Yaml().loadAll(input.inputStream()).forEach { configFile ->
395-
project.logger.debug(
396-
"Section '${configFile}' in configuration file '${input.name}' is valid.")
403+
project.logger.debug("Section '{}' in configuration file '{}' is valid.", configFile, input.name)
397404
}
398405
project.logger.lifecycle("File '${input.name}' passed validation.")
399406
}
@@ -473,10 +480,10 @@ tasks.withType<com.github.spotbugs.snom.SpotBugsTask>() {
473480
reports.maybeCreate("html").required.set(true)
474481
}
475482

476-
tasks.withType<ca.cutterslade.gradle.analyze.AnalyzeDependenciesTask>() {
477-
warnUsedUndeclared = true
478-
warnUnusedDeclared = true
479-
}
483+
//tasks.withType<ca.cutterslade.gradle.analyze.AnalyzeDependenciesTask>() {
484+
// warnUsedUndeclared = true
485+
// warnUnusedDeclared = true
486+
//}
480487

481488
// Task Dependencies
482489
tasks.named("buildDockerImage") {

autobot/src/main/java/com/jdpgrailsdev/oasis/timeline/data/Tweet.java

+19-10
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,12 @@ public class Tweet {
4646
* Creates a new tweet.
4747
*
4848
* @param text The text of the tweet.
49-
* @throws TweetException if the provided text is blank.
5049
*/
51-
public Tweet(final String text) throws TweetException {
52-
53-
if (StringUtils.hasText(text)) {
54-
if (text.length() > TWEET_LIMIT) {
55-
messages = splitTweet(text);
56-
} else {
57-
messages = Lists.newArrayList(text);
58-
}
50+
private Tweet(final String text) {
51+
if (text.length() > TWEET_LIMIT) {
52+
messages = splitTweet(text);
5953
} else {
60-
throw new TweetException("Tweet message may not be blank.");
54+
messages = Lists.newArrayList(text);
6155
}
6256
}
6357

@@ -89,6 +83,21 @@ public List<TweetCreateRequest> getReplies(final String inReplyToStatusId) {
8983
.collect(Collectors.toList());
9084
}
9185

86+
/**
87+
* Creates a new tweet from the provided text.
88+
*
89+
* @param text The text of the Tweet.
90+
* @return a new {@link Tweet} instance
91+
* @throws TweetException if the provided text is blank.
92+
*/
93+
public static Tweet createTweet(final String text) throws TweetException {
94+
if (StringUtils.hasText(text)) {
95+
return new Tweet(text);
96+
} else {
97+
throw new TweetException("Tweet message may not be blank.");
98+
}
99+
}
100+
92101
private TweetCreateRequest createTweet(final String text, final String inReplyToStatusId) {
93102
final TweetCreateRequest tweetCreateRequest = new TweetCreateRequest();
94103
tweetCreateRequest.setText(text.trim());

autobot/src/main/java/com/jdpgrailsdev/oasis/timeline/util/TweetFormatUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public Tweet generateTweet(final TimelineData timelineData, final List<String> a
9090
.build();
9191

9292
final String text = textTemplateEngine.process("tweet", context);
93-
return new Tweet(text);
93+
return Tweet.createTweet(text);
9494
}
9595

9696
@VisibleForTesting

autobot/src/test/java/com/jdpgrailsdev/oasis/timeline/data/TweetTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class TweetTests {
3434
@Test
3535
@DisplayName("test that when a tweet is created for a blank status, an exception is raised")
3636
void testExceptionForBlankTweet() {
37-
Assertions.assertThrows(TweetException.class, () -> new Tweet(null));
37+
Assertions.assertThrows(TweetException.class, () -> Tweet.createTweet(null));
3838

39-
Assertions.assertThrows(TweetException.class, () -> new Tweet(""));
39+
Assertions.assertThrows(TweetException.class, () -> Tweet.createTweet(""));
4040
}
4141

4242
@Test
@@ -53,7 +53,7 @@ void testFirstTweetRetrieved() throws TweetException {
5353
+ "turpis ac lacus aliquam, et vestibulum erat laoreet. Nullam pretium elit sit "
5454
+ "amet dui maximus, tempor lobortis gravida.";
5555

56-
final Tweet tweet = new Tweet(text);
56+
final Tweet tweet = Tweet.createTweet(text);
5757
final TweetCreateRequest mainTweet = tweet.getMainTweet();
5858

5959
assertEquals(
@@ -82,7 +82,7 @@ void testSplittingLongTweet() throws TweetException {
8282
+ "Shakermaker, Fade Away, Digsy's Dinner, Live Forever, Bring It On Down "
8383
+ "(Noel Gallagher attacked on stage during song).";
8484

85-
final Tweet tweet = new Tweet(text);
85+
final Tweet tweet = Tweet.createTweet(text);
8686

8787
assertEquals(3, tweet.getMessages().size());
8888
assertTrue(tweet.getMessages().get(0).length() <= Tweet.TWEET_LIMIT);
@@ -120,7 +120,7 @@ void testSplitTweetSentenceEnd() throws TweetException {
120120
+ "Noel Gallagher, who sees his brother's band perform live for the first "
121121
+ "time.\n\n@liamGallagher @noelgallagher @boneheadspage @TonyMcCarrolls #Oasis "
122122
+ "#TodayInMusic #britpop";
123-
final Tweet tweet = new Tweet(text);
123+
final Tweet tweet = Tweet.createTweet(text);
124124

125125
assertEquals(2, tweet.getMessages().size());
126126
assertTrue(tweet.getMessages().get(0).length() <= Tweet.TWEET_LIMIT);

gradle.properties

-21
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,6 @@ description="An interactive timeline of events for the rock band Oasis"
55
group=com.jdpgrailsdev
66
version=1.0.0-SNAPSHOT
77

8-
#
9-
# Dependencies
10-
#
11-
checkstyle.version=10.9.2
12-
commons-io.version=2.11.0
13-
google-java-format.version=1.16.0
14-
guava.version=31.1-jre
15-
jackson-datatype-jsr310.version=2.15.1
16-
jacoco.version=0.8.8
17-
micrometer-registry-new-relic.version=0.10.0
18-
mockito-core.version=5.3.1
19-
newrelic.version=8.0.1
20-
node.version=21.3.0
21-
okhttp3.version=4.11.0
22-
pmd.version=6.55.0
23-
scribejava-core.version=8.3.3
24-
snakeyaml.version=2.0
25-
spotbugs.version=4.7.3
26-
spring-cloud-starter-contract-stub-runner.version=4.0.1
27-
twitter-api-java-sdk.version=2.0.3
28-
298
#
309
# Gradle arguments
3110
#

gradle/libs.versions.toml

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
[versions]
2-
checkstyle = "10.12.1"
3-
commons-io = "2.13.0"
4-
google-java-format = "1.17.0"
5-
guava = "32.1.1-jre"
6-
jackson-datatype-jsr310 = "2.15.2"
7-
jacoco = "0.8.10"
8-
jedis = "4.4.3"
9-
jedis-mock = "1.0.9"
2+
checkstyle = "10.12.6"
3+
commons-io = "2.15.1"
4+
google-java-format = "1.18.1"
5+
guava = "32.1.3-jre"
6+
jackson-datatype-jsr310 = "2.16.0"
7+
jacoco = "0.8.11"
8+
jedis = "5.1.0"
9+
jedis-mock = "1.0.13"
1010
junit = "5.9.3"
1111
micrometer-registry-new-relic = "0.10.0"
12-
mockito-core = "5.4.0"
13-
newrelic = "8.4.0"
14-
node = "21.2.0"
15-
okhttp3 = "4.11.0"
16-
pmd = "6.55.0"
12+
mockito-core = "5.8.0"
13+
newrelic = "8.7.0"
14+
node = "21.3.0"
15+
okhttp3 = "4.12.0"
16+
pmd = "7.0.0-rc4"
1717
scribejava-core = "8.3.3"
18-
snakeyaml = "2.0"
19-
spotbugs = "4.7.3"
20-
spring-cloud-starter-contract-stub-runner = "4.0.3"
21-
spring-data-redis = "3.1.2"
22-
spring-security-test = "6.1.1"
18+
snakeyaml = "2.2"
19+
spotbugs = "4.8.3"
20+
spring-cloud-starter-contract-stub-runner = "4.1.0"
21+
spring-data-redis = "3.2.1"
22+
spring-security-test = "6.2.0"
2323
twitter-api-java-sdk = "2.0.3"
2424

2525
[libraries]
@@ -50,12 +50,12 @@ redis = [ "jedis", "spring.data.redis" ]
5050
[plugins]
5151
ca-cutterslade-analyze = { id = "ca.cutterslade.analyze", version = "1.9.1" }
5252
docker-gradle = { id = "com.bmuschko.docker-remote-api", version = "9.3.1" }
53-
git-publish = { id = "org.ajoberstar.git-publish", version = "4.2.0" }
53+
git-publish = { id = "org.ajoberstar.git-publish", version = "4.2.1" }
5454
gradle-git-properties = { id = "com.gorylenko.gradle-git-properties", version = "2.4.1" }
5555
heroku-gradle = { id = "com.heroku.sdk.heroku-gradle", version = "3.0.0" }
56-
node-gradle = { id = "com.github.node-gradle.node", version = "5.0.0" }
57-
spotbugs-gradle = { id = "com.github.spotbugs", version = "5.0.14" }
58-
spotless = { id = "com.diffplug.spotless", version = "6.20.0" }
56+
node-gradle = { id = "com.github.node-gradle.node", version = "7.0.1" }
57+
spotbugs-gradle = { id = "com.github.spotbugs", version = "6.0.4" }
58+
spotless = { id = "com.diffplug.spotless", version = "6.23.3" }
5959
spring-boot = { id = "org.springframework.boot", version = "3.2.0" }
60-
spring-dependency-management = { id = "io.spring.dependency-management", version = "1.1.2" }
61-
versions-gradle = { id = "com.github.ben-manes.versions", version = "0.47.0" }
60+
spring-dependency-management = { id = "io.spring.dependency-management", version = "1.1.4" }
61+
versions-gradle = { id = "com.github.ben-manes.versions", version = "0.50.0" }

0 commit comments

Comments
 (0)