versions
versions copied to clipboard
Remove usages of deprecated Maven 2 references (like maven-compat)
we should migrate all to new Maven 3 replacements
MavenProjectBuilder projectBuilder, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver
#559
Next one: #713
Working on migrating to Maven 3.
Please one by one if possible 😄
I think the hardest part was #825, the rest should be easy 😄
@slawekjaranowski I have a question.
Do we still need to provide Maven 2 backward compatibility in case of plugin repos? I've created this, but am now thinking whether it is really needed...
/**
* Provides backward-compat with 2.x that allowed plugins like the maven-remote-resources-plugin:1.0 to
* populate the builder configuration with model repositories instead of artifact repositories.
*
* @param repositories list of remote repositories
* @param session {@link RepositorySystemSession} instance
* @param repositorySystem {@link RepositorySystem} instance
* @return list of repositories converted to {@link ArtifactRepository} objects
* @throws InvalidRepositoryException if the remote repository cannot be reconstructed
*
* @since 2.14.0
*/
public static List<ArtifactRepository> normalizeToArtifactRepositories( List<?> repositories,
RepositorySystemSession session,
RepositorySystem repositorySystem )
throws InvalidRepositoryException
{
try
{
return repositories
.stream()
.filter( o -> o instanceof Repository )
.map( o -> (Repository) o )
.map( r ->
{
try
{
ArtifactRepository repo = repositorySystem.buildArtifactRepository( r );
repositorySystem.injectMirror( session, singletonList( repo ) );
repositorySystem.injectProxy( session, singletonList( repo ) );
repositorySystem.injectAuthentication( session, singletonList( repo ) );
return repo;
}
catch ( InvalidRepositoryException e )
{
throw new IllegalArgumentException( e );
}
} )
.collect( Collectors.toList() );
}
catch ( IllegalArgumentException e )
{
throw (InvalidRepositoryException) e.getCause();
}
}
NO, to remove, I saw similar code in Maven core - not needed in plugin
Good, we also have Maven 2 compat code in DisplayPluginUpdates, I'll remove that too.
So this whole procedure is not necessary anymore?
/**
* Retrieves the standalone superproject
*
* @param projectBuilder {@link ProjectBuilder} instance
* @param mavenSession {@link MavenSession} instance
* @param logger The logger to log tog
*
* @return superproject retrieved
* @throws ProjectBuildingException if the retrieval fails
*/
public static MavenProject getStandaloneSuperProject( ProjectBuilder projectBuilder,
MavenSession mavenSession,
Log logger ) throws ProjectBuildingException
{
ProjectBuildingResult result = projectBuilder.build( new UrlModelSource(
Objects.requireNonNull( PomHelper.class.getResource( "standalone.xml" ) ) ),
createProjectBuilderRequest( mavenSession, r -> r.setProcessPlugins( false ) ) );
if ( result.getProblems() != null )
{
logger.warn( "Problems encountered during building of the superproject." );
result.getProblems().forEach( p ->
logger.warn( "\t" + p.getMessage() ) );
}
return result.getProject();
}
used in:
getLog().debug( "Using Maven 2.x strategy to determine superpom defined plugins" );
Map<String, String> superPomPluginManagement;
try
{
superPomPluginManagement = new HashMap<>( getPluginManagement(
PomHelper.getStandaloneSuperProject( projectBuilder, session, getLog() ).getOriginalModel() ) );
}
catch ( ProjectBuildingException e )
{
throw new MojoExecutionException( "Could not determine the super pom.xml", e );
}
@slawekjaranowski
Wagon -> straight to Transporter
I really, really hope it's the right way I'm following. I got it from this picture: https://maven.apache.org/resolver/
Wagon is delegated to by Transporter, but I believe it's the future-proof interface.
After two of #828, #829, #831 have been merged, I'll update the last one to also remove maven-compat
from dependencies as it will not be needed when all of them are merged, and this ticket can then be closed.
I have a question. I wanted to remove the maven-compat
dependency altogether, but then I faced a problem: there was no provider for the RepositorySystem
interface anymore. I see that Maven uses LegacyRepositorySystem
from maven-compat
.
Which one should I use instead?
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException role: org.apache.maven.repository.RepositorySystem roleHint:
Can be closed @slawekjaranowski
I have a question. I wanted to remove the
maven-compat
dependency altogether, but then I faced a problem: there was no provider for theRepositorySystem
interface anymore. I see that Maven usesLegacyRepositorySystem
frommaven-compat
.Which one should I use instead?
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException role: org.apache.maven.repository.RepositorySystem roleHint:
as usual Maven dev list is the best place to ask, please provide which methods we use from RepositorySystem
Can be closed @slawekjaranowski
I hope yes - very good job @ajarmoniuk thanks