protected void mergeComponentsWithMainAssembly()

in src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java [317:364]


    protected void mergeComponentsWithMainAssembly(
            final Assembly assembly,
            final File assemblyDir,
            final AssemblerConfigurationSource configSource,
            ComponentXpp3Reader.ContentTransformer transformer)
            throws AssemblyReadException {
        final Locator locator = new Locator();

        if (assemblyDir != null && assemblyDir.exists() && assemblyDir.isDirectory()) {
            locator.addStrategy(new RelativeFileLocatorStrategy(assemblyDir));
        }

        // allow absolute paths in componentDescriptor... MASSEMBLY-486
        locator.addStrategy(new RelativeFileLocatorStrategy(configSource.getBasedir()));
        locator.addStrategy(new FileLocatorStrategy());
        locator.addStrategy(new ClasspathResourceLocatorStrategy());

        final AssemblyExpressionEvaluator aee = new AssemblyExpressionEvaluator(configSource);

        final List<String> componentLocations = assembly.getComponentDescriptors();

        for (String location : componentLocations) {
            // allow expressions in path to component descriptor... MASSEMBLY-486
            try {
                location = aee.evaluate(location).toString();
            } catch (final Exception eee) {
                LOGGER.error("Error interpolating componentDescriptor: " + location, eee);
            }

            final Location resolvedLocation = locator.resolve(location);

            if (resolvedLocation == null) {
                throw new AssemblyReadException("Failed to locate component descriptor: " + location);
            }

            Component component = null;
            try (Reader reader = new InputStreamReader(resolvedLocation.getInputStream())) {
                component = new ComponentXpp3Reader(transformer).read(reader);
            } catch (final IOException | XmlPullParserException e) {
                throw new AssemblyReadException(
                        "Error reading component descriptor: " + location + " (resolved to: "
                                + resolvedLocation.getSpecification() + ")",
                        e);
            }

            mergeComponentWithAssembly(component, assembly);
        }
    }