protected Mojo lookupMojo()

in maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java [208:247]


    protected Mojo lookupMojo(String[] coord, XmlNode pluginConfiguration, PluginDescriptor descriptor)
            throws Exception {
        // pluginkey = groupId : artifactId : version : goal
        Mojo mojo = lookup(Mojo.class, coord[0] + ":" + coord[1] + ":" + coord[2] + ":" + coord[3]);
        for (MojoDescriptor mojoDescriptor : descriptor.getMojos()) {
            if (Objects.equals(
                    mojoDescriptor.getImplementation(), mojo.getClass().getName())) {
                if (pluginConfiguration != null) {
                    pluginConfiguration = finalizeConfig(pluginConfiguration, mojoDescriptor);
                }
            }
        }
        if (pluginConfiguration != null) {
            Session session = getContainer().lookup(Session.class);
            Project project;
            try {
                project = getContainer().lookup(Project.class);
            } catch (ComponentLookupException e) {
                project = null;
            }
            org.apache.maven.plugin.MojoExecution mojoExecution;
            try {
                MojoExecution me = getContainer().lookup(MojoExecution.class);
                mojoExecution = new org.apache.maven.plugin.MojoExecution(
                        new org.apache.maven.model.Plugin(me.getPlugin()), me.getGoal(), me.getExecutionId());
            } catch (ComponentLookupException e) {
                mojoExecution = null;
            }
            ExpressionEvaluator evaluator = new WrapEvaluator(
                    getContainer(), new PluginParameterExpressionEvaluatorV4(session, project, mojoExecution));
            ComponentConfigurator configurator = new EnhancedComponentConfigurator();
            configurator.configureComponent(
                    mojo,
                    new XmlPlexusConfiguration(new Xpp3Dom(pluginConfiguration)),
                    evaluator,
                    getContainer().getContainerRealm());
        }

        return mojo;
    }