Restore compatibility on SettingsBuilder, ToolchainsBuilder and MojoDescriptorCreator (#820)

This commit is contained in:
Guillaume Nodet 2022-10-11 16:31:57 +02:00 committed by GitHub
parent 3bc2cf6a7a
commit 3f90e7028e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 61 additions and 59 deletions

View File

@ -86,8 +86,8 @@ public class DefaultWagonManager
if ( id.equalsIgnoreCase( server.getId() ) ) if ( id.equalsIgnoreCase( server.getId() ) )
{ {
SettingsDecryptionResult result = settingsDecrypter.decrypt( SettingsDecryptionResult result = settingsDecrypter.decrypt(
new DefaultSettingsDecryptionRequest( server.getDelegate() ) ); new DefaultSettingsDecryptionRequest( server ) );
server = new Server( result.getServer() ); server = result.getServer();
AuthenticationInfo authInfo = new AuthenticationInfo(); AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName( server.getUsername() ); authInfo.setUserName( server.getUsername() );
@ -125,8 +125,8 @@ public class DefaultWagonManager
if ( proxy.isActive() && protocol.equalsIgnoreCase( proxy.getProtocol() ) ) if ( proxy.isActive() && protocol.equalsIgnoreCase( proxy.getProtocol() ) )
{ {
SettingsDecryptionResult result = settingsDecrypter.decrypt( SettingsDecryptionResult result = settingsDecrypter.decrypt(
new DefaultSettingsDecryptionRequest( proxy.getDelegate() ) ); new DefaultSettingsDecryptionRequest( proxy ) );
proxy = new Proxy( result.getProxy() ); proxy = result.getProxy();
ProxyInfo proxyInfo = new ProxyInfo(); ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost( proxy.getHost() ); proxyInfo.setHost( proxy.getHost() );

View File

@ -563,9 +563,9 @@ public class LegacyRepositorySystem
if ( server != null ) if ( server != null )
{ {
SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( server.getDelegate() ); SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( server );
SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); SettingsDecryptionResult result = settingsDecrypter.decrypt( request );
server = new Server( result.getServer() ); server = result.getServer();
if ( logger.isDebugEnabled() ) if ( logger.isDebugEnabled() )
{ {
@ -670,9 +670,9 @@ public class LegacyRepositorySystem
if ( proxy != null ) if ( proxy != null )
{ {
SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( proxy.getDelegate() ); SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( proxy );
SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); SettingsDecryptionResult result = settingsDecrypter.decrypt( request );
proxy = new org.apache.maven.settings.Proxy( result.getProxy() ); proxy = result.getProxy();
if ( logger.isDebugEnabled() ) if ( logger.isDebugEnabled() )
{ {

View File

@ -194,8 +194,8 @@ public class DefaultRepositorySystemSessionFactory
request.getWorkspaceReader() != null ? request.getWorkspaceReader() : workspaceRepository ); request.getWorkspaceReader() != null ? request.getWorkspaceReader() : workspaceRepository );
DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest(); DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
decrypt.setProxies( Proxy.proxyToApiV4( request.getProxies() ) ); decrypt.setProxies( request.getProxies() );
decrypt.setServers( Server.serverToApiV4( request.getServers() ) ); decrypt.setServers( request.getServers() );
SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt ); SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt );
if ( logger.isDebugEnabled() ) if ( logger.isDebugEnabled() )
@ -215,7 +215,7 @@ public class DefaultRepositorySystemSessionFactory
session.setMirrorSelector( mirrorSelector ); session.setMirrorSelector( mirrorSelector );
DefaultProxySelector proxySelector = new DefaultProxySelector(); DefaultProxySelector proxySelector = new DefaultProxySelector();
for ( org.apache.maven.api.settings.Proxy proxy : decrypted.getProxies() ) for ( Proxy proxy : decrypted.getProxies() )
{ {
AuthenticationBuilder authBuilder = new AuthenticationBuilder(); AuthenticationBuilder authBuilder = new AuthenticationBuilder();
authBuilder.addUsername( proxy.getUsername() ).addPassword( proxy.getPassword() ); authBuilder.addUsername( proxy.getUsername() ).addPassword( proxy.getPassword() );
@ -226,7 +226,7 @@ public class DefaultRepositorySystemSessionFactory
session.setProxySelector( proxySelector ); session.setProxySelector( proxySelector );
DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector(); DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector();
for ( org.apache.maven.api.settings.Server server : decrypted.getServers() ) for ( Server server : decrypted.getServers() )
{ {
AuthenticationBuilder authBuilder = new AuthenticationBuilder(); AuthenticationBuilder authBuilder = new AuthenticationBuilder();
authBuilder.addUsername( server.getUsername() ).addPassword( server.getPassword() ); authBuilder.addUsername( server.getUsername() ).addPassword( server.getPassword() );
@ -235,7 +235,7 @@ public class DefaultRepositorySystemSessionFactory
if ( server.getConfiguration() != null ) if ( server.getConfiguration() != null )
{ {
Dom dom = server.getConfiguration(); Dom dom = ( ( org.codehaus.plexus.util.xml.Xpp3Dom ) server.getConfiguration() ).getDom();
List<Dom> children = dom.getChildren().stream() List<Dom> children = dom.getChildren().stream()
.filter( c -> !"wagonProvider".equals( c.getName() ) ) .filter( c -> !"wagonProvider".equals( c.getName() ) )
.collect( Collectors.toList() ); .collect( Collectors.toList() );

View File

@ -371,9 +371,9 @@ public class DefaultLifecycleExecutionPlanCalculator
mojoExecution.setConfiguration( finalConfiguration ); mojoExecution.setConfiguration( finalConfiguration );
} }
private Xpp3Dom getMojoConfiguration( MojoDescriptor mojoDescriptor ) private Dom getMojoConfiguration( MojoDescriptor mojoDescriptor )
{ {
return MojoDescriptorCreator.convert( mojoDescriptor ); return MojoDescriptorCreator.convert( mojoDescriptor ).getDom();
} }
@Override @Override

View File

@ -102,7 +102,7 @@ public class MojoDescriptorCreator
return null; return null;
} }
public static Xpp3Dom convert( MojoDescriptor mojoDescriptor ) public static org.codehaus.plexus.util.xml.Xpp3Dom convert( MojoDescriptor mojoDescriptor )
{ {
PlexusConfiguration c = mojoDescriptor.getMojoConfiguration(); PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();
@ -125,7 +125,7 @@ public class MojoDescriptorCreator
} }
Xpp3Dom dom = new Xpp3Dom( "configuration", null, null, children, null ); Xpp3Dom dom = new Xpp3Dom( "configuration", null, null, children, null );
return dom; return new org.codehaus.plexus.util.xml.Xpp3Dom( dom );
} }
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process@executionId // org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process@executionId

View File

@ -26,7 +26,6 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.apache.maven.api.settings.Settings;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.properties.internal.SystemProperties; import org.apache.maven.properties.internal.SystemProperties;
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;

View File

@ -22,7 +22,6 @@ package org.apache.maven.settings;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.apache.maven.api.settings.Settings;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

View File

@ -41,6 +41,7 @@ import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.rtinfo.RuntimeInformation; import org.apache.maven.rtinfo.RuntimeInformation;
import org.apache.maven.session.scope.internal.SessionScope; import org.apache.maven.session.scope.internal.SessionScope;
import org.apache.maven.toolchain.DefaultToolchainManagerPrivate; import org.apache.maven.toolchain.DefaultToolchainManagerPrivate;
import org.apache.maven.toolchain.building.ToolchainsBuilder;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.testing.PlexusTest; import org.codehaus.plexus.testing.PlexusTest;
import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystem;

View File

@ -291,7 +291,7 @@ public class LifecycleExecutorTest
MojoDescriptor mojoDescriptor = MojoDescriptor mojoDescriptor =
mojoDescriptorCreator.getMojoDescriptor( "org.apache.maven.its.plugins:maven-it-plugin:0.1:java", session, mojoDescriptorCreator.getMojoDescriptor( "org.apache.maven.its.plugins:maven-it-plugin:0.1:java", session,
session.getCurrentProject() ); session.getCurrentProject() );
Dom dom = MojoDescriptorCreator.convert( mojoDescriptor ); Dom dom = MojoDescriptorCreator.convert( mojoDescriptor ).getDom();
System.out.println( dom ); System.out.println( dom );
} }

View File

@ -73,7 +73,6 @@ import org.apache.maven.shared.utils.logging.MessageUtils;
import org.apache.maven.toolchain.building.DefaultToolchainsBuildingRequest; import org.apache.maven.toolchain.building.DefaultToolchainsBuildingRequest;
import org.apache.maven.toolchain.building.ToolchainsBuilder; import org.apache.maven.toolchain.building.ToolchainsBuilder;
import org.apache.maven.toolchain.building.ToolchainsBuildingResult; import org.apache.maven.toolchain.building.ToolchainsBuildingResult;
import org.apache.maven.toolchain.model.PersistedToolchains;
import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.DefaultPlexusContainer;
@ -1335,7 +1334,7 @@ public class MavenCli
eventSpyDispatcher.onEvent( toolchainsResult ); eventSpyDispatcher.onEvent( toolchainsResult );
executionRequestPopulator.populateFromToolchains( cliRequest.request, executionRequestPopulator.populateFromToolchains( cliRequest.request,
new PersistedToolchains( toolchainsResult.getEffectiveToolchains() ) ); toolchainsResult.getEffectiveToolchains() );
if ( !toolchainsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled() ) if ( !toolchainsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled() )
{ {

View File

@ -35,11 +35,12 @@ import org.apache.maven.cli.CLIManager;
import org.apache.maven.cli.CliRequest; import org.apache.maven.cli.CliRequest;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequestPopulationException; import org.apache.maven.execution.MavenExecutionRequestPopulationException;
import org.apache.maven.api.settings.Mirror; import org.apache.maven.settings.Mirror;
import org.apache.maven.api.settings.Proxy; import org.apache.maven.settings.Profile;
import org.apache.maven.api.settings.Repository; import org.apache.maven.settings.Proxy;
import org.apache.maven.api.settings.Server; import org.apache.maven.settings.Repository;
import org.apache.maven.api.settings.Settings; import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.SettingsUtils; import org.apache.maven.settings.SettingsUtils;
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
import org.apache.maven.settings.building.SettingsBuilder; import org.apache.maven.settings.building.SettingsBuilder;
@ -188,7 +189,7 @@ public class SettingsXmlConfigurationProcessor
for ( Server server : settings.getServers() ) for ( Server server : settings.getServers() )
{ {
request.addServer( new org.apache.maven.settings.Server( server ) ); request.addServer( server );
} }
// <proxies> // <proxies>
@ -210,7 +211,7 @@ public class SettingsXmlConfigurationProcessor
continue; continue;
} }
request.addProxy( new org.apache.maven.settings.Proxy( proxy ) ); request.addProxy( proxy );
} }
// <mirrors> // <mirrors>
@ -223,14 +224,14 @@ public class SettingsXmlConfigurationProcessor
for ( Mirror mirror : settings.getMirrors() ) for ( Mirror mirror : settings.getMirrors() )
{ {
request.addMirror( new org.apache.maven.settings.Mirror( mirror ) ); request.addMirror( mirror );
} }
request.setActiveProfiles( settings.getActiveProfiles() ); request.setActiveProfiles( settings.getActiveProfiles() );
for ( org.apache.maven.api.settings.Profile rawProfile : settings.getProfiles() ) for ( Profile rawProfile : settings.getProfiles() )
{ {
request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile ) ); request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile.getDelegate() ) );
if ( settings.getActiveProfiles().contains( rawProfile.getId() ) ) if ( settings.getActiveProfiles().contains( rawProfile.getId() ) )
{ {
@ -239,8 +240,8 @@ public class SettingsXmlConfigurationProcessor
{ {
try try
{ {
request.addRemoteRepository( MavenRepositorySystem.buildArtifactRepository( request.addRemoteRepository(
new org.apache.maven.settings.Repository( remoteRepository ) ) ); MavenRepositorySystem.buildArtifactRepository( remoteRepository ) );
} }
catch ( InvalidRepositoryException e ) catch ( InvalidRepositoryException e )
{ {
@ -254,7 +255,7 @@ public class SettingsXmlConfigurationProcessor
try try
{ {
request.addPluginArtifactRepository( MavenRepositorySystem.buildArtifactRepository( request.addPluginArtifactRepository( MavenRepositorySystem.buildArtifactRepository(
new org.apache.maven.settings.Repository( pluginRepository ) ) ); pluginRepository ) );
} }
catch ( InvalidRepositoryException e ) catch ( InvalidRepositoryException e )
{ {

View File

@ -34,7 +34,7 @@ import javax.inject.Singleton;
import org.apache.maven.building.FileSource; import org.apache.maven.building.FileSource;
import org.apache.maven.building.Source; import org.apache.maven.building.Source;
import org.apache.maven.api.settings.Settings; import org.apache.maven.api.settings.Settings;
import org.apache.maven.api.settings.TrackableBase; import org.apache.maven.settings.TrackableBase;
import org.apache.maven.settings.io.SettingsParseException; import org.apache.maven.settings.io.SettingsParseException;
import org.apache.maven.settings.io.SettingsReader; import org.apache.maven.settings.io.SettingsReader;
import org.apache.maven.settings.io.SettingsWriter; import org.apache.maven.settings.io.SettingsWriter;
@ -128,7 +128,8 @@ public class DefaultSettingsBuilder
throw new SettingsBuildingException( problems.getProblems() ); throw new SettingsBuildingException( problems.getProblems() );
} }
return new DefaultSettingsBuildingResult( userSettings, problems.getProblems() ); return new DefaultSettingsBuildingResult( new org.apache.maven.settings.Settings( userSettings ),
problems.getProblems() );
} }
private boolean hasErrors( List<SettingsProblem> problems ) private boolean hasErrors( List<SettingsProblem> problems )

View File

@ -22,7 +22,7 @@ package org.apache.maven.settings.building;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.maven.api.settings.Settings; import org.apache.maven.settings.Settings;
/** /**
* Collects the output of the settings builder. * Collects the output of the settings builder.

View File

@ -21,7 +21,7 @@ package org.apache.maven.settings.building;
import java.util.List; import java.util.List;
import org.apache.maven.api.settings.Settings; import org.apache.maven.settings.Settings;
/** /**
* Collects the output of the settings builder. * Collects the output of the settings builder.

View File

@ -26,8 +26,8 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.apache.maven.api.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.api.settings.Server; import org.apache.maven.settings.Server;
import org.apache.maven.settings.building.DefaultSettingsProblem; import org.apache.maven.settings.building.DefaultSettingsProblem;
import org.apache.maven.settings.building.SettingsProblem; import org.apache.maven.settings.building.SettingsProblem;
import org.apache.maven.settings.building.SettingsProblem.Severity; import org.apache.maven.settings.building.SettingsProblem.Severity;
@ -61,9 +61,11 @@ public class DefaultSettingsDecrypter
for ( Server server : request.getServers() ) for ( Server server : request.getServers() )
{ {
server = server.clone();
try try
{ {
server = server.withPassword( decrypt( server.getPassword() ) ); server.setPassword( decrypt( server.getPassword() ) );
} }
catch ( SecDispatcherException e ) catch ( SecDispatcherException e )
{ {
@ -73,7 +75,7 @@ public class DefaultSettingsDecrypter
try try
{ {
server = server.withPassphrase( decrypt( server.getPassphrase() ) ); server.setPassphrase( decrypt( server.getPassphrase() ) );
} }
catch ( SecDispatcherException e ) catch ( SecDispatcherException e )
{ {
@ -90,7 +92,7 @@ public class DefaultSettingsDecrypter
{ {
try try
{ {
proxy = proxy.withPassword( decrypt( proxy.getPassword() ) ); proxy.setPassword( decrypt( proxy.getPassword() ) );
} }
catch ( SecDispatcherException e ) catch ( SecDispatcherException e )
{ {

View File

@ -23,9 +23,9 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.maven.api.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.api.settings.Server; import org.apache.maven.settings.Server;
import org.apache.maven.api.settings.Settings; import org.apache.maven.settings.Settings;
/** /**
* Collects parameters that control the decryption of settings. * Collects parameters that control the decryption of settings.

View File

@ -22,8 +22,8 @@ package org.apache.maven.settings.crypto;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.maven.api.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.api.settings.Server; import org.apache.maven.settings.Server;
import org.apache.maven.settings.building.SettingsProblem; import org.apache.maven.settings.building.SettingsProblem;
/** /**

View File

@ -21,8 +21,8 @@ package org.apache.maven.settings.crypto;
import java.util.List; import java.util.List;
import org.apache.maven.api.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.api.settings.Server; import org.apache.maven.settings.Server;
/** /**
* Collects parameters that control the decryption of settings. * Collects parameters that control the decryption of settings.

View File

@ -21,8 +21,8 @@ package org.apache.maven.settings.crypto;
import java.util.List; import java.util.List;
import org.apache.maven.api.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.api.settings.Server; import org.apache.maven.settings.Server;
import org.apache.maven.settings.building.SettingsProblem; import org.apache.maven.settings.building.SettingsProblem;
/** /**

View File

@ -88,8 +88,8 @@ public class DefaultToolchainsBuilder
throw new ToolchainsBuildingException( problems.getProblems() ); throw new ToolchainsBuildingException( problems.getProblems() );
} }
return new DefaultToolchainsBuildingResult(
return new DefaultToolchainsBuildingResult( merged, problems.getProblems() ); new org.apache.maven.toolchain.model.PersistedToolchains( merged ), problems.getProblems() );
} }
private PersistedToolchains interpolate( PersistedToolchains toolchains, ProblemCollector problems ) private PersistedToolchains interpolate( PersistedToolchains toolchains, ProblemCollector problems )

View File

@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.maven.building.Problem; import org.apache.maven.building.Problem;
import org.apache.maven.api.toolchain.PersistedToolchains; import org.apache.maven.toolchain.model.PersistedToolchains;
/** /**
* Holds the result of the merged toolchains and holds the problems during this build, if any. * Holds the result of the merged toolchains and holds the problems during this build, if any.

View File

@ -22,7 +22,7 @@ package org.apache.maven.toolchain.building;
import java.util.List; import java.util.List;
import org.apache.maven.building.Problem; import org.apache.maven.building.Problem;
import org.apache.maven.api.toolchain.PersistedToolchains; import org.apache.maven.toolchain.model.PersistedToolchains;
/** /**
* Collects the output of the toolchains builder. * Collects the output of the toolchains builder.

View File

@ -39,7 +39,6 @@ import java.io.InputStream;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -240,7 +239,8 @@ public class DefaultToolchainsBuilderTest
ToolchainsBuildingResult result = toolchainBuilder.build( request ); ToolchainsBuildingResult result = toolchainBuilder.build( request );
String interpolatedValue = "testValue"; String interpolatedValue = "testValue";
assertEquals(interpolatedValue, result.getEffectiveToolchains().getToolchains().get(0).getProvides().get( "key" ) ); assertEquals(interpolatedValue, result.getEffectiveToolchains().getToolchains().get(0).getProvides().get( "key" ) );
Xpp3Dom toolchainConfiguration = (Xpp3Dom) result.getEffectiveToolchains().getToolchains().get(0).getConfiguration(); org.codehaus.plexus.util.xml.Xpp3Dom toolchainConfiguration =
(org.codehaus.plexus.util.xml.Xpp3Dom) result.getEffectiveToolchains().getToolchains().get(0).getConfiguration();
assertEquals(interpolatedValue, toolchainConfiguration.getChild("jdkHome").getValue()); assertEquals(interpolatedValue, toolchainConfiguration.getChild("jdkHome").getValue());
assertNotNull( result.getProblems() ); assertNotNull( result.getProblems() );
assertEquals( 0, result.getProblems().size() ); assertEquals( 0, result.getProblems().size() );