Skip to content

Commit

Permalink
Merge pull request #514 from mezarin/eclipse202406Updates2
Browse files Browse the repository at this point in the history
Updates to support Eclipse 2024-06
  • Loading branch information
scottkurz authored Aug 9, 2024
2 parents 8eea9fb + b6d9aa2 commit 57e74f5
Show file tree
Hide file tree
Showing 40 changed files with 678 additions and 749 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
runtime: [ linux, mac, windows ]
targetPlatform: [ 1Q2024 ]
targetPlatform: [ 3Q2024 ]
include:
- runtime: linux
os: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Bundle-Version: 24.0.6.qualifier
Bundle-Activator: io.openliberty.tools.eclipse.ls.plugin.LibertyToolsLSPlugin
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: io.openliberty.tools.eclipse.lsp4e
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: com.google.gson,
org.eclipse.lsp4mp.jdt.core,
org.eclipse.lsp4jakarta.jdt.core,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Bundle-Name: Liberty Tools
Bundle-Vendor: Open Liberty
Bundle-SymbolicName: io.openliberty.tools.eclipse.product;singleton:=true
Bundle-Version: 24.0.6.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-RequiredExecutionEnvironment: JavaSE-21
Automatic-Module-Name: io.openliberty.tools.eclipse
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Export-Package: io.openliberty.tools.eclipse;x-friends:="io.openliberty.tools.ec
io.openliberty.tools.eclipse.ui.preferences;x-friends:="io.openliberty.tools.eclipse.tests"
Require-Bundle: org.eclipse.ui,
org.eclipse.m2e.maven.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-RequiredExecutionEnvironment: JavaSE-21
Automatic-Module-Name: io.openliberty.tools.eclipse.ui
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.cdt.launch.ui,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* Copyright (c) 2023, 2024 IBM Corporation 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
Expand Down Expand Up @@ -33,6 +33,7 @@
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.gradle.tooling.BuildException;
import org.gradle.tooling.GradleConnector;
import org.gradle.tooling.ProjectConnection;
import org.gradle.tooling.model.ExternalDependency;
Expand All @@ -42,9 +43,16 @@
import io.openliberty.tools.eclipse.DevModeOperations;
import io.openliberty.tools.eclipse.Project;
import io.openliberty.tools.eclipse.ui.launch.StartTab;
import io.openliberty.tools.eclipse.utils.Utils;

public class LibertySourcePathComputer implements ISourcePathComputerDelegate {

/**
* Gradle distribution that supports Java 21.
* Gradle version 8.4+ supports Java 21.
*/
private static String GRADLE_DISTRIBUTION_VERISION = "8.8";

ArrayList<IRuntimeClasspathEntry> unresolvedClasspathEntries;

@Override
Expand Down Expand Up @@ -132,12 +140,40 @@ private List<IProject> getProjectDependencies(Project project) throws CoreExcept
}
}
} else {
GradleConnector connector = GradleConnector.newConnector();
connector.forProjectDirectory(project.getIProject().getLocation().toFile());
ProjectConnection connection = connector.connect();
ProjectConnection connection = getProjectGradleConnection(project.getIProject(), null);

try {
EclipseProject eclipseProject = connection.getModel(EclipseProject.class);
EclipseProject eclipseProject = null;

try {
eclipseProject = connection.getModel(EclipseProject.class);
} catch(BuildException e) {
// When using Eclipse IDE 2024-06, this exception could have been caused by the
// Gradle tooling API using a Gradle distribution that does not support Java 21.
//
// Per the GradleConnector documentation, if no Gradle version is defined for the
// build (Gradle wrapper properties file), the connection will use the tooling API's
// version as the Gradle version to run the build.
// Therefore, if a Gradle version is not defined for the build and given that the
// tooling version currently being used is 8.1.1, Gradle 8.1.1
// is downloaded and used by the connector. Gradle 8.1.1 does not support Java 21,
// which causes runtime issues (Unsupported class file major version 65).
// As a workaround, specify a Java 21 compatible Gradle version that the tooling
// can use (i.e. 8.4+). Note that since it is preferable to use the default version
// provided by the tooling API, setting the version can be revised at a later time.
Throwable rootCause = Utils.findRootCause(e);
if (rootCause != null && rootCause instanceof IllegalArgumentException) {
String message = rootCause.getMessage();

if (message != null && message.contains("Unsupported class file major version 65")) {
connection = getProjectGradleConnection(project.getIProject(), GRADLE_DISTRIBUTION_VERISION);
eclipseProject = connection.getModel(EclipseProject.class);
}
} else {
throw e;
}
}

for (ExternalDependency externalDependency : eclipseProject.getClasspath()) {

GradleModuleVersion gradleModuleVersion = externalDependency.getGradleModuleVersion();
Expand All @@ -156,6 +192,26 @@ private List<IProject> getProjectDependencies(Project project) throws CoreExcept
return projectDependencies;
}

/**
* Returns a connection to the input gradle project.
*
* @param project The Gradle project.
* @param gradleDistVersion The gradle distribution version to be used by the
* Gradle API tooling.
*
* @return A connection to the input gradle project.
*/
private ProjectConnection getProjectGradleConnection(IProject project, String gradleDistVersion) {
GradleConnector connector = GradleConnector.newConnector();

if (gradleDistVersion != null) {
connector.useGradleVersion(gradleDistVersion);
}

connector.forProjectDirectory(project.getLocation().toFile());
return connector.connect();
}

/**
* Get project if found in local workspace based on artifact coordinates
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 IBM Corporation and others.
* Copyright (c) 2022, 2024 IBM Corporation 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
Expand Down Expand Up @@ -253,4 +253,24 @@ public static String objectsToString(Object... objects) {

return sb.toString();
}

/**
* Returns the input throwable's root throwable cause.
*
* @param t The parent throwable.
*
* @return The input throwable's root throwable cause.
*/
public static Throwable findRootCause(Throwable t) {
if (t == null) {
return null;
}

Throwable cause = t;
while (cause.getCause() != null && cause.getCause() != cause) {
cause = cause.getCause();
}

return cause;
}
}
2 changes: 1 addition & 1 deletion ci/jenkins/release
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent any

tools {
jdk 'java17-semeru'
jdk 'jdk-semeru-21.0.3'
maven 'maven-3.9.6'
}

Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent any

tools {
jdk 'java17-semeru'
jdk 'jdk-semeru-21.0.3'
xvfb 'gui-test'
maven 'maven-3.9.6'
gradle 'gradle-7.6.1'
Expand Down
48 changes: 24 additions & 24 deletions ci/scans/dependency-only-mend-pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 IBM Corporation and others.
Copyright (c) 2023, 2024 IBM Corporation 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
Expand Down Expand Up @@ -107,7 +107,7 @@ OTHER REFERENCES: https://projects.eclipse.org/projects/eclipse.platform/develo
<mp.ls.version>0.10.0</mp.ls.version>
</properties>

<!-- Updated for Eclipse 2023-12 (4.30.0) -->
<!-- Updated for Eclipse 2024-06 (4.32.0) -->
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand All @@ -117,12 +117,12 @@ OTHER REFERENCES: https://projects.eclipse.org/projects/eclipse.platform/develo
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt</artifactId>
<version>3.19.300</version>
<version>3.19.400</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.36.0</version>
<version>3.37.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
Expand All @@ -132,105 +132,105 @@ OTHER REFERENCES: https://projects.eclipse.org/projects/eclipse.platform/develo
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.debug.ui</artifactId>
<version>3.13.200</version>
<version>3.13.300</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.launching</artifactId>
<version>3.21.0</version>
<version>3.21.100</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.ui</artifactId>
<version>3.31.0</version>
<version>3.32.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.jface.text</artifactId>
<version>3.24.200</version>
<version>3.25.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.lsp4j</groupId>
<artifactId>org.eclipse.lsp4j</artifactId>
<version>0.21.1</version>
<version>0.22.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.lsp4j</groupId>
<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId>
<version>0.21.1</version>
<version>0.22.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.commands</artifactId>
<version>3.11.200</version>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.expressions</artifactId>
<version>3.9.200</version>
<version>3.9.300</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.jobs</artifactId>
<version>3.15.100</version>
<version>3.15.200</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
<version>3.20.0</version>
<version>3.20.100</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>3.30.0</version>
<version>3.31.0</version>
</dependency>
<dependency>
<!-- org.eclipse.debug.core, org.eclipse.debug.core.model -->
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.debug.core</artifactId>
<version>3.21.200</version>
<version>3.21.300</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.debug.ui</artifactId>
<version>3.18.200</version>
<version>3.18.300</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.preferences</artifactId>
<version>3.10.400</version>
<version>3.11.0</version>
</dependency>
<dependency>
<!-- org.osgi.framework, org.eclipse.osgi.service.debug -->
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.18.600</version>
<version>3.19.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt</artifactId>
<version>3.124.200</version>
<version>3.125.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.ui</artifactId>
<version>3.205.0</version>
<version>3.205.100</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.ui.ide</artifactId>
<version>3.22.0</version>
<version>3.22.100</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.ui.editors</artifactId>
<version>3.17.100</version>
<version>3.17.200</version>
</dependency>
<dependency>
<!-- org.eclipse.ui.handlers, org.eclipse.ui.plugin -->
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.ui.workbench</artifactId>
<version>3.131.0</version>
<version>3.131.100</version>
</dependency>

<!-- Copy/paste from bundles/io.openliberty.tools.eclipse.lsp4e/pom.xml (there seems to be a more elegant way to do this in Mend if anyone want to take this on -->
Expand Down
11 changes: 6 additions & 5 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This guide provides detailed instructions on how to use Liberty Tools for the Ec
* [Accessing Liberty Tools Operations](#accessing-liberty-tools-operations)
+ [Using the Liberty dashboard view](#using-the-liberty-dashboard-view)
+ [Using the Project Explorer view](#using-the-project-explorer-view)
* [Running your application on Liberty using dev mode](#running-your-application-on-liberty-using-dev-mode-1)
* [Running your application on Liberty using dev mode](#running-your-application-on-liberty-using-dev-mode)
+ [Start](#start)
+ [Start with Configuration](#start-with-configuration)
+ [Start in container](#start-in-container)
Expand Down Expand Up @@ -46,11 +46,12 @@ This guide provides detailed instructions on how to use Liberty Tools for the Ec
| 23.0.12 | 2023-09 - Eclipse v4.29 |
| 24.0.3 | 2023-12 - Eclipse v4.30 |
| 24.0.6 | 2024-03 - Eclipse v4.31 |
| 24.0.9 | 2024-06 - Eclipse v4.32 |

**NOTE:** Tested with each of the `Eclipse IDE for Enterprise Java and Web Developers` and `Eclipse IDE for Java Developers` packages


2. **Java:** The Eclipse IDE itself requires Java 17. However, the application runtime [can be run with other versions of Java](#start-with-configuration), as long as they are supported by Liberty.
2. **Java:** The Eclipse IDE itself requires Java 21. However, the application runtime [can be run with other versions of Java](#start-with-configuration), as long as they are supported by Liberty.
3. [**Liberty Tools**](installation.md)


Expand All @@ -64,7 +65,7 @@ This guide provides detailed instructions on how to use Liberty Tools for the Ec

- Liberty Maven Plugin -> 3.7.1

- Liberty Gradle Plugin -> 3.5.1
- Liberty Gradle Plugin -> 3.8

### Maven and Gradle

Expand All @@ -83,7 +84,7 @@ Since Liberty dev mode uses the Liberty Maven or Gradle plugins to manage a Mave
- Set the Maven/Gradle installation to use.
- click on **Apply and Close** to save your changes.

3. If a Maven/Gradle installation is still not found, Liberty Tools looks at the PATH environment variable for install locations. See the instructions in [the following section](#Docker) which can also apply to finding Maven or Gradle executables.
3. If a Maven/Gradle installation is still not found, Liberty Tools looks at the PATH environment variable for install locations. See the instructions in [the following section](#docker) which can also apply to finding Maven or Gradle executables.

### Docker

Expand Down Expand Up @@ -310,7 +311,7 @@ The Gradle Eclipse plugins (Buildship) run a simple Gradle build upon import (**

If this build does not complete successfully, the Liberty Tools function might not work correctly.

For example, if your project uses a Gradle wrapper at a Gradle version less than v7.3, it does not support Java 17 per [matrix](https://docs.gradle.org/current/userguide/compatibility.html), but the Java 17+ workspace JRE is required for running Liberty Tools.
For example, if your project uses a Gradle wrapper at a Gradle version less than v8.4, it does not support Java 21 per [matrix](https://docs.gradle.org/current/userguide/compatibility.html), but the Java 21+ workspace JRE is required for running Liberty Tools.

One approach to resolve this incompatibility is to configure the preference at:
**Preferences -> Gradle -> Java home** to refer to a Java installation that is compatible with the level of Gradle in your `gradlew` wrapper.
Expand Down
Loading

0 comments on commit 57e74f5

Please sign in to comment.