Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usages of deprecated Maven 2 references (like maven-compat) #704

Closed
slachiewicz opened this issue Sep 18, 2022 · 15 comments
Closed
Milestone

Comments

@slachiewicz
Copy link
Member

we should migrate all to new Maven 3 replacements

MavenProjectBuilder projectBuilder,
ArtifactMetadataSource artifactMetadataSource,
WagonManager wagonManager,
ArtifactResolver artifactResolver

@slachiewicz
Copy link
Member Author

#559

@slawekjaranowski
Copy link
Member

Next one: #713

@andrzejj0
Copy link
Contributor

Working on migrating to Maven 3.

@slawekjaranowski
Copy link
Member

Please one by one if possible 😄

andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 23, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 23, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 23, 2022
@andrzejj0
Copy link
Contributor

andrzejj0 commented Nov 23, 2022

I think the hardest part was #825, the rest should be easy 😄

andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 24, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 24, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 24, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 24, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 24, 2022
@andrzejj0
Copy link
Contributor

andrzejj0 commented Nov 25, 2022

@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();
    }
}

@slawekjaranowski
Copy link
Member

NO, to remove, I saw similar code in Maven core - not needed in plugin

@andrzejj0
Copy link
Contributor

Good, we also have Maven 2 compat code in DisplayPluginUpdates, I'll remove that too.

@andrzejj0
Copy link
Contributor

andrzejj0 commented Nov 25, 2022

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

andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 25, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 25, 2022
@andrzejj0
Copy link
Contributor

andrzejj0 commented Nov 25, 2022

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.

andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 25, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 25, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 25, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 26, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 26, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 26, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 26, 2022
@andrzejj0
Copy link
Contributor

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.

andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 27, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 27, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 27, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 29, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 30, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 30, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Nov 30, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 1, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 1, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 1, 2022
slawekjaranowski pushed a commit that referenced this issue Dec 2, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 2, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 2, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 3, 2022
@andrzejj0
Copy link
Contributor

andrzejj0 commented Dec 3, 2022

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:

andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 3, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 3, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 4, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Dec 4, 2022
@andrzejj0
Copy link
Contributor

Can be closed @slawekjaranowski

@slawekjaranowski
Copy link
Member

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:

as usual Maven dev list is the best place to ask,
please provide which methods we use from RepositorySystem

@slawekjaranowski
Copy link
Member

Can be closed @slawekjaranowski

I hope yes - very good job @ajarmoniuk thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants