Fix deprecation warnings

This commit is contained in:
Guillaume Nodet 2024-11-29 14:29:40 +01:00
parent cf421eee87
commit c1cd0c0dc1
13 changed files with 30 additions and 18 deletions

View File

@ -34,6 +34,7 @@ public interface ArtifactFilterManager {
* @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin * @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin
* extensions. * extensions.
*/ */
@Deprecated
ArtifactFilter getArtifactFilter(); ArtifactFilter getArtifactFilter();
/** /**
@ -50,6 +51,7 @@ public interface ArtifactFilterManager {
* @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin * @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin
* extensions. * extensions.
*/ */
@Deprecated
void excludeArtifact(String artifactId); void excludeArtifact(String artifactId);
Set<String> getCoreArtifactExcludes(); Set<String> getCoreArtifactExcludes();

View File

@ -34,6 +34,7 @@ import org.apache.maven.settings.Mirror;
*/ */
@Named @Named
@Singleton @Singleton
@Deprecated
public class DefaultMirrorSelector implements MirrorSelector { public class DefaultMirrorSelector implements MirrorSelector {
private static final String WILDCARD = "*"; private static final String WILDCARD = "*";

View File

@ -131,11 +131,6 @@ import org.slf4j.LoggerFactory;
import static java.util.Comparator.comparing; import static java.util.Comparator.comparing;
import static org.apache.maven.api.Constants.MAVEN_HOME; import static org.apache.maven.api.Constants.MAVEN_HOME;
import static org.apache.maven.api.Constants.MAVEN_INSTALLATION_CONF; import static org.apache.maven.api.Constants.MAVEN_INSTALLATION_CONF;
import static org.apache.maven.cli.CLIManager.BATCH_MODE;
import static org.apache.maven.cli.CLIManager.COLOR;
import static org.apache.maven.cli.CLIManager.FORCE_INTERACTIVE;
import static org.apache.maven.cli.CLIManager.NON_INTERACTIVE;
import static org.apache.maven.cli.ResolveFile.resolveFile;
// TODO push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs // TODO push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs
@ -488,7 +483,7 @@ public class MavenCli {
// LOG COLOR // LOG COLOR
String styleColor = cliRequest.getUserProperties().getProperty("style.color", "auto"); String styleColor = cliRequest.getUserProperties().getProperty("style.color", "auto");
styleColor = cliRequest.getUserProperties().getProperty(Constants.MAVEN_STYLE_COLOR_PROPERTY, styleColor); styleColor = cliRequest.getUserProperties().getProperty(Constants.MAVEN_STYLE_COLOR_PROPERTY, styleColor);
styleColor = commandLine.getOptionValue(COLOR, styleColor); styleColor = commandLine.getOptionValue(CLIManager.COLOR, styleColor);
if ("always".equals(styleColor) || "yes".equals(styleColor) || "force".equals(styleColor)) { if ("always".equals(styleColor) || "yes".equals(styleColor) || "force".equals(styleColor)) {
MessageUtils.setColorEnabled(true); MessageUtils.setColorEnabled(true);
} else if ("never".equals(styleColor) || "no".equals(styleColor) || "none".equals(styleColor)) { } else if ("never".equals(styleColor) || "no".equals(styleColor) || "none".equals(styleColor)) {
@ -497,8 +492,9 @@ public class MavenCli {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Invalid color configuration value '" + styleColor + "'. Supported are 'auto', 'always', 'never'."); "Invalid color configuration value '" + styleColor + "'. Supported are 'auto', 'always', 'never'.");
} else { } else {
boolean isBatchMode = !commandLine.hasOption(FORCE_INTERACTIVE) boolean isBatchMode = !commandLine.hasOption(CLIManager.FORCE_INTERACTIVE)
&& (commandLine.hasOption(BATCH_MODE) || commandLine.hasOption(NON_INTERACTIVE)); && (commandLine.hasOption(CLIManager.BATCH_MODE)
|| commandLine.hasOption(CLIManager.NON_INTERACTIVE));
if (isBatchMode || commandLine.hasOption(CLIManager.LOG_FILE)) { if (isBatchMode || commandLine.hasOption(CLIManager.LOG_FILE)) {
MessageUtils.setColorEnabled(false); MessageUtils.setColorEnabled(false);
} }
@ -520,7 +516,7 @@ public class MavenCli {
// LOG STREAMS // LOG STREAMS
if (commandLine.hasOption(CLIManager.LOG_FILE)) { if (commandLine.hasOption(CLIManager.LOG_FILE)) {
File logFile = new File(commandLine.getOptionValue(CLIManager.LOG_FILE)); File logFile = new File(commandLine.getOptionValue(CLIManager.LOG_FILE));
logFile = resolveFile(logFile, cliRequest.workingDirectory); logFile = ResolveFile.resolveFile(logFile, cliRequest.workingDirectory);
// redirect stdout and stderr to file // redirect stdout and stderr to file
try { try {
@ -926,7 +922,7 @@ public class MavenCli {
if (extClassPath != null && !extClassPath.isEmpty()) { if (extClassPath != null && !extClassPath.isEmpty()) {
for (String jar : extClassPath.split(File.pathSeparator)) { for (String jar : extClassPath.split(File.pathSeparator)) {
File file = resolveFile(new File(jar), cliRequest.workingDirectory); File file = ResolveFile.resolveFile(new File(jar), cliRequest.workingDirectory);
slf4jLogger.debug(" included '{}'", file); slf4jLogger.debug(" included '{}'", file);
@ -1200,7 +1196,7 @@ public class MavenCli {
if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) { if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) {
userToolchainsFile = new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_USER_TOOLCHAINS)); userToolchainsFile = new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_USER_TOOLCHAINS));
userToolchainsFile = resolveFile(userToolchainsFile, cliRequest.workingDirectory); userToolchainsFile = ResolveFile.resolveFile(userToolchainsFile, cliRequest.workingDirectory);
if (!userToolchainsFile.isFile()) { if (!userToolchainsFile.isFile()) {
throw new FileNotFoundException( throw new FileNotFoundException(
@ -1218,7 +1214,8 @@ public class MavenCli {
if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_INSTALLATION_TOOLCHAINS)) { if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_INSTALLATION_TOOLCHAINS)) {
installationToolchainsFile = installationToolchainsFile =
new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_INSTALLATION_TOOLCHAINS)); new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_INSTALLATION_TOOLCHAINS));
installationToolchainsFile = resolveFile(installationToolchainsFile, cliRequest.workingDirectory); installationToolchainsFile =
ResolveFile.resolveFile(installationToolchainsFile, cliRequest.workingDirectory);
if (!installationToolchainsFile.isFile()) { if (!installationToolchainsFile.isFile()) {
throw new FileNotFoundException( throw new FileNotFoundException(
@ -1227,7 +1224,8 @@ public class MavenCli {
} else if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)) { } else if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)) {
installationToolchainsFile = installationToolchainsFile =
new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)); new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS));
installationToolchainsFile = resolveFile(installationToolchainsFile, cliRequest.workingDirectory); installationToolchainsFile =
ResolveFile.resolveFile(installationToolchainsFile, cliRequest.workingDirectory);
if (!installationToolchainsFile.isFile()) { if (!installationToolchainsFile.isFile()) {
throw new FileNotFoundException( throw new FileNotFoundException(
@ -1238,7 +1236,8 @@ public class MavenCli {
cliRequest.getUserProperties().getProperty(Constants.MAVEN_INSTALLATION_TOOLCHAINS); cliRequest.getUserProperties().getProperty(Constants.MAVEN_INSTALLATION_TOOLCHAINS);
if (installationToolchainsFileStr != null) { if (installationToolchainsFileStr != null) {
installationToolchainsFile = new File(installationToolchainsFileStr); installationToolchainsFile = new File(installationToolchainsFileStr);
installationToolchainsFile = resolveFile(installationToolchainsFile, cliRequest.workingDirectory); installationToolchainsFile =
ResolveFile.resolveFile(installationToolchainsFile, cliRequest.workingDirectory);
} }
} }
@ -1377,11 +1376,11 @@ public class MavenCli {
private void disableInteractiveModeIfNeeded(final CliRequest cliRequest, final MavenExecutionRequest request) { private void disableInteractiveModeIfNeeded(final CliRequest cliRequest, final MavenExecutionRequest request) {
CommandLine commandLine = cliRequest.getCommandLine(); CommandLine commandLine = cliRequest.getCommandLine();
if (commandLine.hasOption(FORCE_INTERACTIVE)) { if (commandLine.hasOption(CLIManager.FORCE_INTERACTIVE)) {
return; return;
} }
if (commandLine.hasOption(BATCH_MODE) || commandLine.hasOption(NON_INTERACTIVE)) { if (commandLine.hasOption(CLIManager.BATCH_MODE) || commandLine.hasOption(CLIManager.NON_INTERACTIVE)) {
request.setInteractiveMode(false); request.setInteractiveMode(false);
} else { } else {
boolean runningOnCI = isRunningOnCI(cliRequest.getSystemProperties()); boolean runningOnCI = isRunningOnCI(cliRequest.getSystemProperties());
@ -1422,7 +1421,7 @@ public class MavenCli {
File current = baseDirectory; File current = baseDirectory;
if (alternatePomFile != null) { if (alternatePomFile != null) {
current = resolveFile(new File(alternatePomFile), workingDirectory); current = ResolveFile.resolveFile(new File(alternatePomFile), workingDirectory);
} }
if (modelProcessor != null) { if (modelProcessor != null) {
@ -1524,7 +1523,7 @@ public class MavenCli {
final CommandLine commandLine, final CommandLine commandLine,
final MavenExecutionRequest request) { final MavenExecutionRequest request) {
boolean runningOnCI = isRunningOnCI(request.getSystemProperties()); boolean runningOnCI = isRunningOnCI(request.getSystemProperties());
boolean quietCI = runningOnCI && !commandLine.hasOption(FORCE_INTERACTIVE); boolean quietCI = runningOnCI && !commandLine.hasOption(CLIManager.FORCE_INTERACTIVE);
if (quiet || commandLine.hasOption(CLIManager.NO_TRANSFER_PROGRESS) || quietCI) { if (quiet || commandLine.hasOption(CLIManager.NO_TRANSFER_PROGRESS) || quietCI) {
return new QuietMavenTransferListener(); return new QuietMavenTransferListener();

View File

@ -37,6 +37,7 @@ import static java.util.Objects.nonNull;
* Pseudo test to generate documentation fragment about supported CLI options. TODO such documentation generation code * Pseudo test to generate documentation fragment about supported CLI options. TODO such documentation generation code
* should not be necessary as unit test but should be run during site generation (Velocity? Doxia macro?) * should not be necessary as unit test but should be run during site generation (Velocity? Doxia macro?)
*/ */
@Deprecated
class CLIManagerDocumentationTest { class CLIManagerDocumentationTest {
private static final String LS = System.lineSeparator(); private static final String LS = System.lineSeparator();

View File

@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@Deprecated
class CLIReportingUtilsTest { class CLIReportingUtilsTest {
@Test @Test

View File

@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
/** /**
*/ */
@Deprecated
class CleanArgumentTest { class CleanArgumentTest {
@Test @Test

View File

@ -84,6 +84,7 @@ import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@Deprecated
class MavenCliTest { class MavenCliTest {
private MavenCli cli; private MavenCli cli;

View File

@ -40,6 +40,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@Deprecated
class ExecutionEventLoggerTest { class ExecutionEventLoggerTest {
private Logger logger; private Logger logger;

View File

@ -32,6 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
@Deprecated
class MavenPropertiesLoaderTest { class MavenPropertiesLoaderTest {
@Test @Test

View File

@ -38,6 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Unit tests on <code>MavenProperties</code>. * Unit tests on <code>MavenProperties</code>.
*/ */
@Deprecated
public class MavenPropertiesTest { public class MavenPropertiesTest {
private static final String LINE_SEPARATOR = System.getProperty("line.separator"); private static final String LINE_SEPARATOR = System.getProperty("line.separator");

View File

@ -36,6 +36,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@Deprecated
class ConsoleMavenTransferListenerTest { class ConsoleMavenTransferListenerTest {
private CountDownLatch startLatch; private CountDownLatch startLatch;

View File

@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
@Deprecated
class FileSizeFormatTest { class FileSizeFormatTest {
@Test @Test

View File

@ -31,6 +31,7 @@ import org.mockito.Mockito;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
@Deprecated
class SimplexTransferListenerTest { class SimplexTransferListenerTest {
@Test @Test
void cancellation() throws InterruptedException { void cancellation() throws InterruptedException {