diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/OSGiJavaToolchain.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/OSGiJavaToolchain.java index facecd2250..14a77d70f1 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/OSGiJavaToolchain.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/OSGiJavaToolchain.java @@ -16,7 +16,6 @@ import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainPrivate; -import org.apache.maven.toolchain.java.JavaToolchainImpl; import org.codehaus.plexus.util.xml.Xpp3Dom; public class OSGiJavaToolchain implements Toolchain { @@ -38,7 +37,7 @@ public String findTool(String toolName) { } public String getJavaHome() { - if (base instanceof JavaToolchainImpl defaultToolchain) { + if (base instanceof @SuppressWarnings("deprecation") org.apache.maven.toolchain.java.DefaultJavaToolChain defaultToolchain) { return defaultToolchain.getJavaHome(); } if (base instanceof JavaHomeToolchain javaHomeToolchain) { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/ToolchainProvider.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/ToolchainProvider.java index 221af779f4..9102a12eff 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/ToolchainProvider.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/ToolchainProvider.java @@ -28,7 +28,7 @@ import org.apache.maven.toolchain.ToolchainManager; import org.apache.maven.toolchain.ToolchainManagerPrivate; import org.apache.maven.toolchain.ToolchainPrivate; -import org.apache.maven.toolchain.java.JavaToolchainImpl; +import org.apache.maven.toolchain.java.DefaultJavaToolChain; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; @@ -123,8 +123,8 @@ private MavenSession getMavenSession() { } /** - * Finds a matching {@link JavaToolchainImpl} in the maven toolchains for a given maven session - * and toolchain id. Returns the toolchain or null if no toolchain could be found. + * Finds a matching {@link DefaultJavaToolChain} in the maven toolchains for a given maven + * session and toolchain id. Returns the toolchain or null if no toolchain could be found. * * @param session * The maven session @@ -134,13 +134,13 @@ private MavenSession getMavenSession() { * @throws MojoExecutionException * if the toolchains are misconfigured */ - public JavaToolchainImpl findMatchingJavaToolChain(final MavenSession session, final String toolchainId) + public DefaultJavaToolChain findMatchingJavaToolChain(final MavenSession session, final String toolchainId) throws MojoExecutionException { try { final Map requirements = Collections.singletonMap("id", toolchainId); for (ToolchainPrivate javaToolChain : toolChainManager.getToolchainsForType("jdk", session)) { if (javaToolChain.matchesRequirements(requirements) - && javaToolChain instanceof JavaToolchainImpl javaToolchain) { + && javaToolChain instanceof DefaultJavaToolChain javaToolchain) { return javaToolchain; } } diff --git a/tycho-extras/tycho-eclipserun-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java b/tycho-extras/tycho-eclipserun-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java index 76b8f0fca1..5880c7433d 100644 --- a/tycho-extras/tycho-eclipserun-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java +++ b/tycho-extras/tycho-eclipserun-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java @@ -27,7 +27,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.project.MavenProject; -import org.apache.maven.toolchain.java.JavaToolchainImpl; import org.eclipse.sisu.equinox.launching.EquinoxInstallation; import org.eclipse.sisu.equinox.launching.EquinoxLauncher; import org.eclipse.sisu.equinox.launching.LaunchConfiguration; @@ -154,7 +153,9 @@ public void testExecutionEnvironmentIsRespectedDuringDependencyResolution() thro } public void testExecutionEnvironmentIsRespectedDuringEclipseExecution() throws Exception { - JavaToolchainImpl mockToolchainForCustomEE = mock(JavaToolchainImpl.class); + @SuppressWarnings("deprecation") + org.apache.maven.toolchain.java.DefaultJavaToolChain mockToolchainForCustomEE = mock( + org.apache.maven.toolchain.java.DefaultJavaToolChain.class); when(mockToolchainForCustomEE.findTool("java")).thenReturn("/path/to/custom-ee-jdk/bin/java"); when(toolchainProvider.findMatchingJavaToolChain(any(), eq("custom-ee"))).thenReturn(mockToolchainForCustomEE);