Skip to content

Commit

Permalink
Upgrade dependencies and jdk to 21 (#157)
Browse files Browse the repository at this point in the history
* Upgrade dependencies and jdk to 21

A few minor code changes were made for the upgrade, including removing
LspLog (which should have already been removed). I didn't make any larger
changes to make use of java 21 features - that can be done later. The
primary motivation of this commit is to update our dependency on lsp4j,
which outdated and depended on a version of guava with two CVEs out:
CVE-2023-2976, CVE-2020-8908. In order to do so, a jdk upgrade was
required since newer versions of lsp4j are past jdk 8. We were going
to upgrade the jdk soon anways.

Also got rid of an extra signing block in the publishing task, which
is taken care of by jreleaser.
  • Loading branch information
milesziemer authored Jul 30, 2024
1 parent 76c01ce commit 1109260
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [8, 11, 17]
java: [21]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
21 changes: 7 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,18 @@ publishing {
}
}
}

// Don't sign the artifacts if we didn't get a key and password to use.
if (project.hasProperty("signingKey") && project.hasProperty("signingPassword")) {
signing {
useInMemoryPgpKeys(
(String) project.property("signingKey"),
(String) project.property("signingPassword"))
sign(publishing.publications["mavenJava"])
}
}
}


dependencies {
implementation "org.eclipse.lsp4j:org.eclipse.lsp4j:0.20.0"
implementation "org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.1"
implementation "software.amazon.smithy:smithy-build:[smithyVersion, 2.0["
implementation "software.amazon.smithy:smithy-cli:[smithyVersion, 2.0["
implementation "software.amazon.smithy:smithy-model:[smithyVersion, 2.0["
implementation "software.amazon.smithy:smithy-syntax:[smithyVersion, 2.0["

testImplementation "org.junit.jupiter:junit-jupiter:5.10.0"
testImplementation "org.hamcrest:hamcrest:2.1"
testImplementation "org.hamcrest:hamcrest:2.2"

testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}
Expand Down Expand Up @@ -209,8 +199,9 @@ tasks.named("checkstyleTest") {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

jar {
Expand All @@ -224,6 +215,8 @@ jar {
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
exclude "reflect.properties"
// Included by dependencies in later versions of java, causes duplicate entries in the output jar
exclude "**/module-info.class"
}
manifest {
attributes("Main-Class": "software.amazon.smithy.lsp.Main")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

package software.amazon.smithy.lsp;

import org.eclipse.lsp4j.jsonrpc.util.Preconditions;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;
import org.eclipse.lsp4j.util.Preconditions;

public class SelectorParams {
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
import software.amazon.smithy.lsp.document.Document;
import software.amazon.smithy.lsp.document.DocumentParser;
import software.amazon.smithy.lsp.document.DocumentShape;
import software.amazon.smithy.lsp.ext.LspLog;
import software.amazon.smithy.lsp.ext.serverstatus.OpenProject;
import software.amazon.smithy.lsp.ext.serverstatus.ServerStatus;
import software.amazon.smithy.lsp.handler.CompletionHandler;
Expand Down Expand Up @@ -197,12 +196,6 @@ public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
Object initializationOptions = params.getInitializationOptions();
if (initializationOptions instanceof JsonObject) {
JsonObject jsonObject = (JsonObject) initializationOptions;
if (jsonObject.has("logToFile")) {
String setting = jsonObject.get("logToFile").getAsString();
if (setting.equals("enabled")) {
LspLog.enable();
}
}
if (jsonObject.has("diagnostics.minimumSeverity")) {
String configuredMinimumSeverity = jsonObject.get("diagnostics.minimumSeverity").getAsString();
Optional<Severity> severity = Severity.fromString(configuredMinimumSeverity);
Expand Down
137 changes: 0 additions & 137 deletions src/main/java/software/amazon/smithy/lsp/ext/LspLog.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import software.amazon.smithy.build.model.MavenConfig;
import software.amazon.smithy.build.model.MavenRepository;
import software.amazon.smithy.build.model.SmithyBuildConfig;
import software.amazon.smithy.lsp.ext.LspLog;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;
Expand All @@ -32,6 +32,8 @@
* top-level {@code mavenRepositories} and {@code mavenDependencies} properties.
*/
public final class SmithyBuildExtensions implements ToSmithyBuilder<SmithyBuildExtensions> {
private static final Logger LOGGER = Logger.getLogger(SmithyBuildExtensions.class.getName());

private final List<String> imports;
private final List<String> mavenRepositories;
private final List<String> mavenDependencies;
Expand Down Expand Up @@ -157,7 +159,7 @@ public Builder mavenRepositories(Collection<String> mavenRepositories) {
.map(repo -> MavenRepository.builder().url(repo).build())
.collect(Collectors.toList()))
.build();
LspLog.println("Read deprecated `mavenRepositories` in smithy-build.json. Update smithy-build.json to "
LOGGER.warning("Read deprecated `mavenRepositories` in smithy-build.json. Update smithy-build.json to "
+ "{\"maven\": {\"repositories\": [{\"url\": \"repo url\"}]}}");
}

Expand All @@ -181,7 +183,7 @@ public Builder mavenDependencies(Collection<String> mavenDependencies) {
config = config.toBuilder()
.dependencies(mavenDependencies)
.build();
LspLog.println("Read deprecated `mavenDependencies` in smithy-build.json. Update smithy-build.json to "
LOGGER.warning("Read deprecated `mavenDependencies` in smithy-build.json. Update smithy-build.json to "
+ "{\"maven\": {\"dependencies\": [\"dependencyA\", \"dependencyB\"]}}");
}
this.maven = config;
Expand Down

0 comments on commit 1109260

Please sign in to comment.