Skip to content

Commit

Permalink
[TEMP] Revert replacement of DefaultJavaToolChain
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Sep 23, 2023
1 parent 42ed378 commit 3cb4568
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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<String, String> 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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 3cb4568

Please sign in to comment.