Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference
version: 2
updates:
- package-ecosystem: github-actions
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/junit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Publish Unit Test Results

on:
workflow_run:
workflows: ["Validate"]
types:
- completed

jobs:
check:
uses: eclipse-platform/eclipse.platform.releng.aggregator/.github/workflows/publishTestResults.yml@master
76 changes: 62 additions & 14 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,92 @@
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
name: Validate

on:
on: # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows
push:
branches-ignore: # build all branches except:
- 'dependabot/**' # prevent workflow being triggered twice (once for commit to the branch and once for opening/syncing the PR)
tags-ignore: # don't build tags
tags-ignore: # don't build tags
- '**'
paths-ignore:
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
pull_request:
paths-ignore:
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
workflow_dispatch: # https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/

defaults:
run:
shell: bash


jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: Event File
path: ${{ github.event_path }}

###########################################################
build:
runs-on: ${{ matrix.os }}
###########################################################

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: # https://github.com/actions/runner-images#available-images
- ubuntu-latest
- macos-15-intel # Intel
- macos-latest # ARM
- windows-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 20

steps:

- name: Git Checkout
uses: actions/checkout@v4 # https://github.com/actions/checkout
uses: actions/checkout@v5 # https://github.com/actions/checkout

- name: Set up JDK 11 ☕
uses: actions/setup-java@v4

- name: "Install: JDKs for building and testing"
uses: actions/setup-java@v5 # https://github.com/actions/setup-java
with:
java-version: 11
distribution: 'temurin'
distribution: temurin
java-version: |
11
17
21
cache: gradle

- name: Build with Gradle 🏗️
run: ./gradlew build
run: ./gradlew build testOlderJavas

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: Test Results ${{ matrix.os }}
if-no-files-found: warn
path: |
${{ github.workspace }}/**/build/test-results/**/*.xml
${{ github.workspace }}/**/build/reports/


- name: Run API Compare
if: ${{ matrix.os == 'ubuntu-latest' }}
run: ./releng/runjapicmp.sh

- name: Upload API Compare results
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: API Compare results
if-no-files-found: warn
path: |
${{ github.workspace }}/build/p2-repository/japicmp-report/
9 changes: 9 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
org.gradle.daemon=false
org.gradle.java.installations.auto-detect=true
org.gradle.java.installations.auto-download=true

# Optionally, you can hint custom JDK locations (semicolon-separated on Windows):
# org.gradle.java.installations.paths=C:\\jdks\\jdk-11;C:\\jdks\\jdk-21

# To run Gradle itself on a specific JDK (machine-specific), prefer setting JAVA_HOME
# before invoking Gradle or use --java-home on the command line.
84 changes: 83 additions & 1 deletion gradle/java-compiler-settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,32 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
******************************************************************************/

// Use central version from gradle/versions.gradle

// --- Enforce Java version for running Gradle itself ---
def currentJava = JavaVersion.current()
def minJava = JavaVersion.VERSION_17 // xtend requires Java >= 17
def maxJava = JavaVersion.VERSION_21 // Gradle 9.x is required for Java 25

if (currentJava < minJava || currentJava > maxJava) {
throw new GradleException("""
This build must be run with Java between ${minJava} and ${maxJava}.

Current Java:
JavaVersion.current() = ${currentJava}
java.version = ${System.getProperty('java.version')}
java.home = ${System.getProperty('java.home')}

Please switch your JAVA_HOME or use the Gradle wrapper with a compatible JDK.

In addition, to run testOlderJavas tasks Java 17 and Java 11 must be discovrable.
See https://docs.gradle.org/8.6/userguide/toolchains.html#sec:auto_detection
""")
}

java {
sourceCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.toVersion(versions.java)
targetCompatibility = JavaVersion.toVersion(versions.java)
}

tasks.withType(Javadoc) {
Expand All @@ -21,6 +45,8 @@ tasks.withType(Javadoc) {

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
// Ensure cross-compilation targets specified Java version
options.release = versions.java as Integer
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down Expand Up @@ -87,3 +113,59 @@ if (findProperty('ignoreTestFailures') == 'true') {
ignoreFailures = true
}
}

def testDir = file('src/test/java')
def xtendTestClassPatterns = []

if (testDir.exists()) {
testDir.eachFileRecurse { File f ->
if (f.name.endsWith('.xtend')) {
// Path relative to src/test/java, with Unix-ish separators
def rel = testDir.toPath().relativize(f.toPath()).toString()
rel = rel.replace(File.separatorChar, '/' as char)

// Replace .xtend with .class, wildcard anything before it
// e.g. com/foo/BarTest.xtend -> **/com/foo/BarTest.class
def classPattern = "**/${rel[0..-6]}class"
xtendTestClassPatterns << classPattern
}
}
}

tasks.register('testJava11', Test) {
description = 'Runs non-xtend tests on Java 11 JVM'
group = 'verification'

testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath

// Current version of xtend require JVM >= 17 to run,
// so exclude xtend based tests
if (!xtendTestClassPatterns.isEmpty()) {
exclude xtendTestClassPatterns
}

javaLauncher.set(
javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
)
}

tasks.register('testJava17', Test) {
description = 'Runs tests on Java 17 JVM'
group = 'verification'

testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath

javaLauncher.set(
javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
)
}

tasks.register('testOlderJavas') {
dependsOn tasks.named('testJava17'), tasks.named('testJava11')
}
2 changes: 1 addition & 1 deletion gradle/manifest-gen.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def qualifiedVersion = baseVersion + '.v' + buildTime
jar.bundle.bnd (
'Bundle-Version': qualifiedVersion,
'Bundle-Vendor': 'Eclipse LSP4J',
'Bundle-RequiredExecutionEnvironment': 'JavaSE-11',
'Bundle-RequiredExecutionEnvironment': "JavaSE-${versions.java}",
"-exportcontents": "org.eclipse.lsp4j.*",
"-savemanifest": "build/tmp/bnd/MANIFEST.MF",
)
Expand Down
5 changes: 4 additions & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
version = '1.0.0-SNAPSHOT'

ext.versions = [
'xtend_lib': '2.32.0',
// Additional JDK version configuration is in java-compiler-settings
'java': '11',

'xtend_lib': '2.40.0',
'guava': '[32.1.2,34)',
'gson': '[2.9.1,3.0)',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand All @@ -33,8 +36,6 @@
import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer;
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints;
import org.eclipse.xtext.xbase.lib.Pair;
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -63,21 +64,22 @@ public void testRequest() throws Exception {
result.setSupportTerminateDebuggee(true);
result.setSupportsCompletionsRequest(false);

server.expectedRequests.put("initialize", new Pair<>(p, result));
server.expectedRequests.put("initialize", List.of(p, result));
CompletableFuture<Capabilities> future = clientLauncher.getRemoteProxy().initialize(p);
Assert.assertEquals(result.toString(), future.get(TIMEOUT, TimeUnit.MILLISECONDS).toString());
client.joinOnEmpty();
}

static class AssertingEndpoint implements Endpoint {
public Map<String, Pair<Object, Object>> expectedRequests = new LinkedHashMap<>();
public Map<String, List<Object>> expectedRequests = new LinkedHashMap<>();

@Override
public CompletableFuture<?> request(String method, Object parameter) {
Assert.assertTrue(expectedRequests.containsKey(method));
Pair<Object, Object> result = expectedRequests.remove(method);
Assert.assertEquals(result.getKey().toString(), parameter.toString());
return CompletableFuture.completedFuture(result.getValue());
List<Object> result = expectedRequests.remove(method);
Assert.assertEquals(2, result.size());
Assert.assertEquals(result.get(0).toString(), parameter.toString());
return CompletableFuture.completedFuture(result.get(1));
}

public Map<String, Object> expectedNotifications = new LinkedHashMap<>();
Expand Down Expand Up @@ -110,7 +112,7 @@ public void joinOnEmpty() {

@Override
public String toString() {
return new ToStringBuilder(this).addAllFields().toString();
return Arrays.toString(new Object[] {expectedRequests, expectedNotifications});
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class JsonRpcDataTransformationContext implements TransformationContext {
def TypeReference getRightType(TypeReference typeReference) {
val type = typeReference.type
if (type === eitherType.type) {
return typeReference.actualTypeArguments.last
return IterableExtensions.lastOrNull(typeReference.actualTypeArguments)
}
if (type instanceof InterfaceDeclaration) {
return type.extendedInterfaces.map[rightType].filterNull.head
Expand Down
9 changes: 2 additions & 7 deletions org.eclipse.lsp4j/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
/******************************************************************************
* Copyright (c) 2016 TypeFox and others.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
******************************************************************************/

ext.title = 'LSP4J'
description = 'Java bindings for the Language Server Protocol'

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

dependencies {
compileOnly project(":org.eclipse.lsp4j.generator")
api project(":org.eclipse.lsp4j.jsonrpc")
Expand Down
Loading
Loading