private void configureComponent()

in src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java [398:434]


    private void configureComponent(
            final Object component, final Xpp3Dom config, final AssemblerConfigurationSource configSource)
            throws ComponentLookupException, ComponentConfigurationException {
        final ComponentConfigurator configurator = container.lookup(ComponentConfigurator.class, "basic");

        final ConfigurationListener listener = new DebugConfigurationListener(LOGGER);

        final ExpressionEvaluator expressionEvaluator = new AssemblyExpressionEvaluator(configSource);

        final XmlPlexusConfiguration configuration = new XmlPlexusConfiguration(config);

        final Object[] containerRealm = getContainerRealm();

        /*
         * NOTE: The signature of configureComponent() has changed in Maven 3.x, the reflection prevents a linkage error
         * and makes the code work with both Maven 2 and 3.
         */
        try {
            final Method configureComponent = ComponentConfigurator.class.getMethod(
                    "configureComponent",
                    Object.class,
                    PlexusConfiguration.class,
                    ExpressionEvaluator.class,
                    (Class<?>) containerRealm[1],
                    ConfigurationListener.class);

            configureComponent.invoke(
                    configurator, component, configuration, expressionEvaluator, containerRealm[0], listener);
        } catch (final NoSuchMethodException | IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (final InvocationTargetException e) {
            if (e.getCause() instanceof ComponentConfigurationException) {
                throw (ComponentConfigurationException) e.getCause();
            }
            throw new RuntimeException(e.getCause());
        }
    }